# aws\_ec2 inventory plugins: Creating host variables based on AWS tags

**URL:** <https://forum.ansible.com/t/aws-ec2-inventory-plugins-creating-host-variables-based-on-aws-tags/31305>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [September 18, 2019, 9:57am UTC](https://forum.ansible.com/t/aws-ec2-inventory-plugins-creating-host-variables-based-on-aws-tags/31305 "2019-09-18T09:57:15Z")\
**Posts on this page:** 1\
**Page:** 1

<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:57am UTC](https://forum.ansible.com/t/aws-ec2-inventory-plugins-creating-host-variables-based-on-aws-tags/31305/1 "2019-09-18T09:57:15Z")

</div>

Is there a way to create host variables based on the tags on an instance? (without manually listing each variable and tag under the compose section)

The idea is bascially to allow the equivalent of the INI-style inventory file using tags from AWS. (With the relevant variables using a prefix to identify them)

e.g. If an instance has these tags: (The array syntax is assumed from what works in the INI-style inventory)  
ansible\_swapfile\_size=4G

ansible\_extra\_packages=[“htop”,“iotop”]

I want these variables to be configured:  
swapfile\_size: 4G

extra\_packages:

- htop
- iotop

compose seems to be capable of doing it if I list a fixed set of variables, but that means that if a new variable are added, the inventory would need to be edited.

Is there a way to dynamically generate variables based on tags?

Thanks,  
Gert
