# Selecting a variable from register

**URL:** <https://forum.ansible.com/t/selecting-a-variable-from-register/20003>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [December 14, 2015, 3:52pm UTC](https://forum.ansible.com/t/selecting-a-variable-from-register/20003 "2015-12-14T15:52:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kjartan\_Clausen](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@Kjartan\_Clausen](https://forum.ansible.com/u/Kjartan_Clausen)\
**Post date:** [December 14, 2015, 3:52pm UTC](https://forum.ansible.com/t/selecting-a-variable-from-register/20003/1 "2015-12-14T15:52:30Z")

</div>

I’m trying to automate creating an AWS VPC with routes, subnets, instances, RDS, etc.  
so I created the following yml:

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 14, 2015, 5:34pm UTC](https://forum.ansible.com/t/selecting-a-variable-from-register/20003/2 "2015-12-14T17:34:39Z")

</div>

Can you please try this:

- debug: var=“{{ item[.id](http://vpc.subnets.id/) }}”  
when: [vpc.subnets.az](http://vpc.subnets.az/) == “{{Azone1}}”  
with\_items: vpc.subnets  
for individual you can get like this but I am not sure:
- debug: var=[vpc.subnets[0].id](http://vpc.subnets.id/)  
when: [vpc.subnets.az](http://vpc.subnets.az/) == “{{Azone1}}”

For complete example, please refer this:  
[https://github.com/arbabnazar/ansible-aws-vpc-ha-wordpress/blob/master/aws/tasks/vpc.yml](https://github.com/arbabnazar/ansible-aws-vpc-ha-wordpress/blob/master/aws/tasks/vpc.yml)  
Thanks,
