# Variable Return Variables.

**URL:** <https://forum.ansible.com/t/variable-return-variables/22332>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [August 20, 2016, 2:54am UTC](https://forum.ansible.com/t/variable-return-variables/22332 "2016-08-20T02:54:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Blackburn](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@David\_Blackburn](https://forum.ansible.com/u/David_Blackburn)\
**Post date:** [August 20, 2016, 2:54am UTC](https://forum.ansible.com/t/variable-return-variables/22332/1 "2016-08-20T02:54:05Z")

</div>

Hi

I am currently using the ec2\_customer\_gateway module, and the variable names it returns are inconsistent, if a gateway exists its plural if not then singular. The problem is I call out this variable later in my code.

CGW doesn’t exist.

“gateway”: {  
**“customer\_gateway”: {**  
“bgp\_asn”: “65248”,  
“customer\_gateway\_id”: “cgw-8c03da92”,

CGW already exists.

“gateway”: {  
**“customer\_gateways”: [**  
{  
“bgp\_asn”: “12345”,  
“customer\_gateway\_id”: “cgw-8c03da92”,

Later in my code I reference the customer\_gateway[s] list which could either be **customer\_gateways or**  **customer\_gateway** , this appears to be a bug in the boto code or aws api but the only way I can think of getting around this is by creating a dummy CGW prior to the real creation and then taking the dummy CGW down after creation. Anyone have a creative way to get around this problem?

# - name: create vpn connection

# ec2\_vpc\_vpn\_connection:

# aws\_access\_key: “{{ assumed\_role.sts\_creds.access\_key }}”

# aws\_secret\_key: “{{ assumed\_role.sts\_creds.secret\_key }}”

# security\_token: “{{ assumed\_role.sts\_creds.session\_token }}”

# name: “VPN {{ vpcname }} {{ item.gateway.customer\_gateways[0].customer\_gateway\_id }}”

# type: ipsec.1

# region: “{{ region }}”

**# customer\_gateway\_id: “{{ item.gateway.customer\_gateways[0].customer\_gateway\_id }}”**

# vpn\_gateway\_id: “{{ vgw.vgw.id }}”

# static\_routes\_only: False

# wait: False

# wait\_timeout: 300

# register: vpn

# with\_items:

# “{{ cgw.results }}”

Thanks  
Dave
