-
Notifications
You must be signed in to change notification settings - Fork 0
/
createIGWandNetworks.yml
75 lines (68 loc) · 1.87 KB
/
createIGWandNetworks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
- hosts: localhost # put localhost. We are processing against aws
connection: local # put local. We are processing against aws
gather_facts: False # don't gather facts against localhost
tasks:
- name: create internet gateway and attach it to VPC
ec2_vpc_igw:
region: "{{ region }}"
vpc_id: "{{ vpc_id }}"
state: "{{ state }}"
tags:
Name: "{{ igw_name }}"
register: igw
- name: Lookup route tables
ec2_vpc_route_table_info:
region: "{{ region }}"
filters:
vpc-id: "{{ vpc_id }}"
register: vpc_route_tables
- name: Setup default route tables
ec2_vpc_route_table:
region: "{{ region }}"
vpc_id: "{{ vpc_id }}"
tags:
Name: PublicRT
lookup: id
purge_subnets: false
route_table_id: "{{ vpc_route_tables.route_tables[0].id }}"
routes:
- dest: 0.0.0.0/0
gateway_id: "{{ igw.gateway_id }}"
- name: associate subnet1 to the VPC
ec2_vpc_subnet:
region: "{{ region }}"
vpc_id: "{{ vpc_id }}"
state: "{{ state }}"
cidr: "{{ subnet_cidr1 }}"
map_public: yes
resource_tags:
Name: "{{ subnet_name1 }}"
register: sn1
- name: Set subnet1 in variable
set_stats:
data:
subnet1: "{{ sn1 }}"
- name: associate subnet2 to the VPC
ec2_vpc_subnet:
region: "{{ region }}"
vpc_id: "{{ vpc_id }}"
state: "{{ state }}"
cidr: "{{ subnet_cidr2 }}"
map_public: yes
resource_tags:
Name: "{{ subnet_name2 }}"
register: sn2
- name: Set subnet2 in variable
set_stats:
data:
subnet2: "{{ sn2 }}"
- name: define route for subnet 2
ec2_vpc_route_table:
region: "{{ region }}"
vpc_id: "{{ vpc_id }}"
subnets:
- "{{ subnet_cidr2 }}"
tags:
Name: "{{ route_name }}"
register: route2