-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute_table.yaml
56 lines (52 loc) · 1.59 KB
/
route_table.yaml
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
---
- name: create public and private route table
hosts: localhost
connection: local
gather_facts: False
vars:
vpc_id: "vpc id"
aws_region: "us-east-1"
aws_access_key: "access key"
aws_secret_key: "secret key"
public_subnet_id: "public subnet id"
private_subnet_id: "private subnet id"
igw_id: "igw id"
nat_gateway_id: "nat gateway id "
# Route Tables.
# one RT for the public subnet,
# and one for the private subnet.
# the Route Table for the private subnet
# will redirect default destinations to the NAT Gateway
# and the Route Table for the public subnet will use the
# Internet Gateway.
#
# the Route Tables will contain
# a route for resources inside the VPC, so that if we need
# to reach an internal resource, we don't go to the Internet
# Gateway or the NAT Gateway.
- name: Set up public subnet route table
ec2_vpc_route_table:
vpc_id: "{{ vpc_id }}"
region: "{{ aws_region }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
tags:
Name: "Public"
subnets:
- "{{ public_subnet_id }}"
routes:
- dest: "0.0.0.0/0"
gateway_id: "{{ igw_id }}"
- name: Set up private subnet route table
ec2_vpc_route_table:
vpc_id: "{{ vpc_id }}"
region: "{{ aws_region }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
tags:
Name: "Private"
subnets:
- "{{ private_subnet_id }}"
routes:
- dest: "0.0.0.0/0"
gateway_id: "{{ nat_gateway_id }}"