# How to use keyed\_groups in constructed EC2 inventory with a single tag?

**URL:** <https://forum.ansible.com/t/how-to-use-keyed-groups-in-constructed-ec2-inventory-with-a-single-tag/27715>\
**Category:** Ansible Project\
**Created:** [June 5, 2018, 9:55pm UTC](https://forum.ansible.com/t/how-to-use-keyed-groups-in-constructed-ec2-inventory-with-a-single-tag/27715 "2018-06-05T21:55:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WhileLoop](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@WhileLoop](https://forum.ansible.com/u/WhileLoop)\
**Post date:** [June 5, 2018, 9:55pm UTC](https://forum.ansible.com/t/how-to-use-keyed-groups-in-constructed-ec2-inventory-with-a-single-tag/27715/1 "2018-06-05T21:55:04Z")

</div>

Currently inventory.aws\_ec2.yaml looks like this:

`  
plugin: aws\_ec2  
regions:

- us-west-2  
keyed\_groups:
- prefix: tag  
key: tags

`

This creates one group for every tag combination. How can make it look at a single tag only? For example if only wanted it to create one group for each value of the “Environment” tag.

---

<div class="post-metadata">

**Author:** ![Gert\_van\_den\_Berg](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@Gert\_van\_den\_Berg](https://forum.ansible.com/u/Gert_van_den_Berg)\
**Post date:** [September 18, 2019, 9:23am UTC](https://forum.ansible.com/t/how-to-use-keyed-groups-in-constructed-ec2-inventory-with-a-single-tag/27715/2 "2019-09-18T09:23:23Z")

</div>

keyed\_groups:

- key: tags.Environment  
separator: ‘’  
prefix: env # This is optional
