# AWS\_EC2 plugin keyed\_groups suffix option

**URL:** <https://forum.ansible.com/t/aws-ec2-plugin-keyed-groups-suffix-option/28790>\
**Category:** Ansible Project\
**Created:** [October 15, 2018, 11:45pm UTC](https://forum.ansible.com/t/aws-ec2-plugin-keyed-groups-suffix-option/28790 "2018-10-15T23:45:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Knights1](https://avatars.discourse-cdn.com/v4/letter/g/82dd89/32.png) [@Guy\_Knights1](https://forum.ansible.com/u/Guy_Knights1)\
**Post date:** [October 15, 2018, 11:45pm UTC](https://forum.ansible.com/t/aws-ec2-plugin-keyed-groups-suffix-option/28790/1 "2018-10-15T23:45:15Z")

</div>

Is there any way to specify a suffix for the keyed\_groups option in the aws\_ec2 inventory plugin? I’m looking at migrating from Ansible 2.4 to 2.6 and would like to switch from the old ec2 dynamic inventory script. However, we currently specify our host groups as “\_servers”, eg. “web\_servers”. Is there any way I can replicate this host group format in the aws\_ec2 plugin or am I out of luck?

I know I could change the format of our host groups but I’d prefer not to have to do that if possible as there are conditional includes, etc I’d have to adjust as well.

Thanks,  
Guy

---

<div class="post-metadata">

**Author:** ![flowerysong1](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@flowerysong1](https://forum.ansible.com/u/flowerysong1)\
**Post date:** [October 16, 2018, 12:07am UTC](https://forum.ansible.com/t/aws-ec2-plugin-keyed-groups-suffix-option/28790/2 "2018-10-16T00:07:06Z")

</div>

Sure, just include the suffix in the key.

`

keyed\_groups:

- prefix: ‘’  
separator: ‘’  
key: tags.Class ~ ‘\_servers’

`

`

“all”: {  
“children”: [  
“aws\_ec2”,  
“builder\_servers”,  
“ctools\_mx\_servers”,  
“dev\_servers”,  
“dnsbl\_servers”,  
“egress\_servers”,  
“jail\_servers”,  
“master\_servers”,  
“mx\_servers”,  
“relay\_egress\_servers”,  
“syslog\_servers”,  
“ungrouped”  
]

`

---

<div class="post-metadata">

**Author:** ![Guy\_Knights1](https://avatars.discourse-cdn.com/v4/letter/g/82dd89/32.png) [@Guy\_Knights1](https://forum.ansible.com/u/Guy_Knights1)\
**Post date:** [October 16, 2018, 12:27am UTC](https://forum.ansible.com/t/aws-ec2-plugin-keyed-groups-suffix-option/28790/3 "2018-10-16T00:27:55Z")

</div>

Great, thanks! That seems to have worked.

One other question related to aws\_ec2 - I usually pass the AWS\_PROFILE var on the command line when I call ansible, eg. “AWS\_PROFILE=myawsprofile ./ansible-playbook -i inventory/prod/ playbooks/site.yml”. However, with my aws\_ec2 inventory file, if I leave out the boto\_profile and regions variables the inventory list returns nothing. I have to explicitly include these two parameters with a specific profile name and region in order for it to return a list of my instances. I tried setting boto\_profile: ‘env:AWS\_PROFILE’ or just ‘AWS\_PROFILE’ (in addition to just leaving it out) but it doesn’t work. What am I doing wrong?

Thanks again,  
Guy

---

<div class="post-metadata">

**Author:** ![Guy\_Knights1](https://avatars.discourse-cdn.com/v4/letter/g/82dd89/32.png) [@Guy\_Knights1](https://forum.ansible.com/u/Guy_Knights1)\
**Post date:** [October 16, 2018, 4:54pm UTC](https://forum.ansible.com/t/aws-ec2-plugin-keyed-groups-suffix-option/28790/4 "2018-10-16T16:54:21Z")

</div>

Never mind, I worked out that if I include the region (but not the boto\_profile parameter) then it works. Not sure why it’s not using the profile region defined in ~/.aws/config but it’s not a big deal.
