VPC
VPC
- name: Create VPC
amazon.aws.ec2_vpc_net:
name: "{{ tags.vpc }}"
cidr_block: "{{ vpc_cidr }}"
state: present
tags:
Name: "{{ tags.vpc }}"
register: vpcout
SUBNET
- name: Create Subnet
amazon.aws.ec2_vpc_subnet:
vpc_id: "{{ vpcout.vpc.id }}"
cidr: "{{ subnet_cidr }}"
az: us-east-1a
map_public: false
tags:
Name: "{{ tags.subnet }}"
register: subnet_out
ROUTE TABLE
- name: Set up public subnet route table
amazon.aws.ec2_vpc_route_table:
state: present
route_table_id: "{{ rts.route_tables[0].route_table_id }}"
vpc_id: "{{ vpcout.vpc.id }}"
tags:
Name: "{{ tags.default_rt }}"
subnets:
- "{{ subnet_out.subnet.id }}"
routes:
- dest: 0.0.0.0/0
gateway_id: "{{ igw.gateway_id }}"
GATEWAY
- name: Create Internet Gateway
amazon.aws.ec2_vpc_igw:
vpc_id: "{{ vpcout.vpc.id }}"
force_attach: true
state: present
tags:
Name: "{{ tags.igw }}"
register: igw
TAG
- name: Tag default route table
amazon.aws.ec2_tag:
resource: "{{ rts.route_tables[0].route_table_id }}"
tags:
Name: "{{ tags.default_rt }}"