ansible_aws_vpc

Provision AWS VPC, Subnets, Internet and NAT gateways and routes.
git clone git://git.beardyjay.co.uk/ansible_aws_vpc
Log | Files | Refs | README

create_nat_gateway.yml (649B)


      1 ---
      2 
      3 - name: get subnet ID for NAT GW deployment
      4   ec2_vpc_subnet_facts:
      5     filters:
      6       vpc-id: "{{ my_vpc.vpc.id }}"
      7       "tag:Name": "{{ vpc.nat_gateway_subnet_name }}"
      8     region: "{{ aws_region }}"
      9   register: nat_gateway_subnet
     10 
     11 - name: fail if more than 1 subnet found
     12   fail:
     13     msg: "Found {{ nat_gateway_subnet.subnets|length }} subnets instead of 1 subnet"
     14   when: 'nat_gateway_subnet.subnets|length != 1'
     15 
     16 - name: create nat gateway
     17   ec2_vpc_nat_gateway:
     18     if_exist_do_not_create: yes
     19     region: "{{ aws_region }}"
     20     state: present
     21     subnet_id: "{{ nat_gateway_subnet.subnets[0].id }}"
     22     wait: yes
     23   register: nat_gateway