-
Notifications
You must be signed in to change notification settings - Fork 12
/
00-vpc.yml
62 lines (54 loc) · 2 KB
/
00-vpc.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
---
- hosts: localhost
connection: local
vars_files:
- vars/all.yml
tasks:
- debug:
msg: "AWS region - {{ aws_region }}, AZ - {{ vpc_subnet_az }}"
- name: create an AWS VPC for use with kubernetes
ec2_vpc:
state: present
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
region: "{{ aws_region }}"
cidr_block: "{{ vpc_network_cidr }}"
resource_tags: { "Name": "kubernetes", "KubernetesCluster": "{{ k8s_cluster_name }}" }
internet_gateway: True
wait: True
subnets:
- cidr: "{{ vpc_public_subnet_cidr }}"
az: "{{ vpc_subnet_az }}"
resource_tags: { "Name" : "{{ vpc_public_subnet_name }}", "KubernetesCluster": "{{ k8s_cluster_name }}" }
- cidr: "{{ vpc_private_subnet_cidr }}"
az: "{{ vpc_subnet_az }}"
resource_tags: { "Name" : "{{ vpc_private_subnet_name }}", "KubernetesCluster": "{{ k8s_cluster_name }}" }
route_tables:
- subnets:
- "{{ vpc_public_subnet_cidr }}"
routes:
- dest: 0.0.0.0/0
gw: igw
# Get information on VPC networks/subnets/etc
- include: vpc-facts.yml
- include: create-vpc-nat-gateway.yml
- debug:
var: vpc_nat_gateway
verbosity: 2
- name: set default gateway for private subnet to nat gateway instance
ec2_vpc_route_table:
vpc_id: "{{ vpc_network_id }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
region: "{{ aws_region }}"
subnets:
- "{{ vpc_private_subnet_id }}"
routes:
- dest: 0.0.0.0/0
gateway_id: "{{ vpc_nat_gateway.nat_gateway_id }}"
instance_id: "{{ vpc_nat_gateway.nat_gateway_id }}"
resource_tags: { "KubernetesCluster": "{{ k8s_cluster_name }}" }
register: vpc_nat_route_table
- debug:
var: vpc_nat_route_table
verbosity: 2