# Best Way to Manage Multiple Environments and Multiple AWS Accounts

**URL:** <https://forum.ansible.com/t/best-way-to-manage-multiple-environments-and-multiple-aws-accounts/19004>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [August 12, 2015, 4:03pm UTC](https://forum.ansible.com/t/best-way-to-manage-multiple-environments-and-multiple-aws-accounts/19004 "2015-08-12T16:03:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![datsun80](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@datsun80](https://forum.ansible.com/u/datsun80)\
**Post date:** [August 12, 2015, 4:03pm UTC](https://forum.ansible.com/t/best-way-to-manage-multiple-environments-and-multiple-aws-accounts/19004/1 "2015-08-12T16:03:57Z")

</div>

I am looking for ways that others have organized their inventory files when they have multiple aws accounts.

Little background, today we have one folder with all inventory files in it. The inventory directory is a mix between static and a dynamic inventory files. I am tagging the ec2 instances so I can call a playbook specifying hosts, stage\_website or prod\_website for example.

We are switching moving all of our separate instances to their own AWS accounts however and this is where I need to find an elegant way to model this. I will have one AWS account for dev, qa, stage, and production. I would like to use the dynamic inventory approach as that supports auto scaling nicely. I looked up using profiles in boto config but it doesn’t look like the ec2.py file supports it.

I did find this: [https://github.com/jjneely/ansible/tree/multiple-aws-accounts/plugins/inventory](https://github.com/jjneely/ansible/tree/multiple-aws-accounts/plugins/inventory) which someone rewrote to support multiple aws accounts which I can use but I wanted to get input on how others have done this before I do.

---

<div class="post-metadata">

**Author:** ![datsun80](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@datsun80](https://forum.ansible.com/u/datsun80)\
**Post date:** [August 13, 2015, 2:36pm UTC](https://forum.ansible.com/t/best-way-to-manage-multiple-environments-and-multiple-aws-accounts/19004/2 "2015-08-13T14:36:50Z")

</div>

Nobody?

---

<div class="post-metadata">

**Author:** ![Martin2](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Martin2](https://forum.ansible.com/u/Martin2)\
**Post date:** [August 13, 2015, 3:03pm UTC](https://forum.ansible.com/t/best-way-to-manage-multiple-environments-and-multiple-aws-accounts/19004/3 "2015-08-13T15:03:48Z")

</div>

I don’t have input on the actual question but I’m interested to hear why one would have multiple AWS account for a given domain (as in responsibility domain, not in DNS domain).

It seems to me that a single domain can be managed by using single account. Combining the accounts into a single ansible managed thing defeats the whole purpose of separating stuff. So the conclusion would be to either have a single account or mutliple ansible “things” that each manage their own responsibility domain. Then again I don’t know the whole picture and my POV is probably very naive.

/Martin

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 13, 2015, 3:05pm UTC](https://forum.ansible.com/t/best-way-to-manage-multiple-environments-and-multiple-aws-accounts/19004/4 "2015-08-13T15:05:50Z")

</div>

I've seen 2 ways to approach this, using boto's builtin profiles to  
manage multiple accounts or create multiple instances of ec2.py and  
ec2.ini for each account and then use -i to point at individual ones  
or keep them in a directory and point at that with ansible.cfg

---

<div class="post-metadata">

**Author:** ![datsun80](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@datsun80](https://forum.ansible.com/u/datsun80)\
**Post date:** [August 13, 2015, 3:07pm UTC](https://forum.ansible.com/t/best-way-to-manage-multiple-environments-and-multiple-aws-accounts/19004/5 "2015-08-13T15:07:45Z")

</div>

It is a business decision to separate the environments for billing reasons.

---

<div class="post-metadata">

**Author:** ![datsun80](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@datsun80](https://forum.ansible.com/u/datsun80)\
**Post date:** [August 13, 2015, 3:16pm UTC](https://forum.ansible.com/t/best-way-to-manage-multiple-environments-and-multiple-aws-accounts/19004/6 "2015-08-13T15:16:51Z")

</div>

I have read about that way too. I like the approach of just specifying a directory with -i and having ansible look at all inventory files but I might have to switch back to specifying the exact inventory I want to work with.

---

<div class="post-metadata">

**Author:** ![datsun80](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@datsun80](https://forum.ansible.com/u/datsun80)\
**Post date:** [August 13, 2015, 9:44pm UTC](https://forum.ansible.com/t/best-way-to-manage-multiple-environments-and-multiple-aws-accounts/19004/7 "2015-08-13T21:44:25Z")

</div>

On second thought, the approach that uses separate directories for each account would not work because the credentials to connect to said accounts are not stored in the ec2.ini file but rather the boto.conf file or environment variables.
