Differentiating between environments using the ec2 dynamic inventory

Hi all,

Suppose I have two environments and in EC2 built with cloudformation and they are grouped or tagged as:

tag_aws_cloudformation_stack_name_example_d1

tag_aws_cloudformation_stack_name_example_d2

within each cloudformation group I will have servers, they are tagged as follows:

ec2:
Role=example_ldap

Ansible:
tag_ec2_Role=example_ldap

I use a limit on my ansible play for one of the grouped environments:

-l tag_aws_cloudformation_stack_name_example_d2

When I run a play, and try to get the hosts of ‘example_ldap’:

hostvars[groups[‘tag_Role_example_ldap’][0]].ec2_tag_Name

I could receive either d1 or d2’s example_ldap host.

Is there a way I can limit what I get back from the ec2 dynamic inventory or do I need to be more specific with my group names, so example_ldap would become example_ldap_d1? Or am I missing out on a better way to achieve this?

Thanks