Variable Return Variables.

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