---
+- assert:
+ that:
+ - vpc_name != ''
+ - vpc_cidr != ''
+ - vpc_region != ''
+ tags: ['check_vars']
+
- name: VPC
+ delegate_to: localhost
+ become: no
ec2_vpc_net:
state: present
name: "{{ vpc_name }}"
cidr_block: "{{ vpc_cidr }}"
region: "{{ vpc_region }}"
- register: vpc
-
-- name: IGW
- ec2_vpc_igw:
- state: present
- vpc_id: "{{ vpc.vpc.id }}"
- region: "{{ vpc_region }}"
- register: igw
-
-- name: Name IGW
- ec2_tag:
- state: present
- resource: "{{ igw.gateway_id }}"
- region: "{{ vpc_region }}"
- tags:
- Name: "igw-{{ vpc_region }}"
-
-- name: Subnets
- with_items: "{{ subnets_pub + subnets_priv }}"
- ec2_vpc_subnet:
- state: present
- vpc_id: "{{ vpc.vpc.id }}"
- region: "{{ vpc_region }}"
- cidr: "{{ item.cidr }}"
- az: "{{ item.az }}"
- tags: "{{ item.resource_tags }}"
-
-- name: Access/NAT EIP
- ec2_eip:
- in_vpc: yes
- region: "{{ vpc_region }}"
- reuse_existing_ip_allowed: yes
- register: access_eip
-
-- name: Private route table
- ec2_vpc_route_table:
- state: present
- vpc_id: "{{ vpc.vpc.id }}"
- region: "{{ vpc_region }}"
- tags:
- Name: "Private-Routes-vpc-{{ vpc_region }}"
- zone: priv
- managed: 'yes'
- subnets: "{{ subnets_priv|map(attribute='cidr')|list }}"
- register: private_rt
-
-- name: Public route table
- ec2_vpc_route_table:
- state: present
- vpc_id: "{{ vpc.vpc.id }}"
- region: "{{ vpc_region }}"
- tags:
- Name: "Public-Routes-vpc-{{ vpc_region }}"
- zone: pub
- managed: 'no'
- subnets: "{{ subnets_pub|map(attribute='cidr')|list }}"
- routes:
- - dest: 0.0.0.0/0
- gateway_id: "{{ igw.gateway_id }}"
- register: public_rt
-
-- name: not implemented yet
- debug:
- msg: |
- Change pub-subnets to auto-assign external IPs
+ register: vpc
\ No newline at end of file