# Matching hosts in AWS (or any dynamic inventory?)

**URL:** <https://forum.ansible.com/t/matching-hosts-in-aws-or-any-dynamic-inventory/25037>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [July 20, 2017, 8:23pm UTC](https://forum.ansible.com/t/matching-hosts-in-aws-or-any-dynamic-inventory/25037 "2017-07-20T20:23:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Matz1](https://avatars.discourse-cdn.com/v4/letter/g/b5e925/32.png) [@Guy\_Matz1](https://forum.ansible.com/u/Guy_Matz1)\
**Post date:** [July 20, 2017, 8:23pm UTC](https://forum.ansible.com/t/matching-hosts-in-aws-or-any-dynamic-inventory/25037/1 "2017-07-20T20:23:24Z")

</div>

Hello!  
I would like to match hosts in AWS with something like (passing env as an extravar):  
hosts: tag\_Function\_www:&ec2\_tag\_Environment=env

I’m currently using this which works:  
hosts: “tag\_Function\_www:&tag\_Environment\_{{ env|default(‘test’) }}”

but wondering if there’s a better way. Any thoughts would be appreciated

Thanks!  
Gu
