This repository has been archived by the owner on Mar 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
close_down_postgres.yml
68 lines (61 loc) · 2.27 KB
/
close_down_postgres.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
---
- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Get VPC
ec2_vpc_net:
state: present
name: "{{ project_slug }}-vpc"
region: "{{ region }}"
cidr_block: 10.0.0.0/16
resource_tags: '{"Name":"{{ project_slug }}_vpc"}'
register: vpc
- name: Create NACL for public subjects
ec2_vpc_nacl:
vpc_id: "{{ vpc.vpc.id }}"
name: "{{ project_slug }}-nacl-public"
region: "{{ region }}"
subnets: ["{{ project_slug }}_subnet_public", "{{ project_slug }}_subnet_public2"]
ingress: [
# rule no, protocol, allow/deny, cidr, icmp_code, icmp_type,
# port from, port to
[100, 'all', 'allow', '0.0.0.0/0', null, null, 80, 80],
[100, 'all', 'allow', '0.0.0.0/0', null, null, 443, 443]
]
egress: [
[100, 'all', 'allow', '0.0.0.0/0', null, null, null, null]
]
state: 'present'
- name: Create NACL for private subjects
ec2_vpc_nacl:
vpc_id: "{{ vpc.vpc.id }}"
name: "{{ project_slug }}-nacl-private"
region: "{{ region }}"
subnets: ["{{ project_slug }}_subnet_private", "{{ project_slug }}_subnet_private2"]
ingress: [
# rule no, protocol, allow/deny, cidr, icmp_code, icmp_type,
# port from, port to
[100, 'all', 'allow', '0.0.0.0/0', null, null, 80, 80],
[100, 'all', 'allow', '0.0.0.0/0', null, null, 443, 443]
]
egress: [
[100, 'all', 'allow', '0.0.0.0/0', null, null, null, null]
]
state: 'present'
- name: Get Private Subnets
ec2_vpc_subnet_facts:
region: "{{ region }}"
filters:
vpc_id: "{{ vpc.vpc.id }}"
"tag:Type": "private"
register: private_subnets
- name: Create RDS subnet group
rds_subnet_group:
region: "{{ region }}"
state: present
name: "{{ project_slug }}-rds-subnet-group"
description: "Database subnet for {{ project_slug }} instance of {{ project }}"
subnets:
"{{ private_subnets.subnets|map(attribute='id')|list }}"
register: "rds_subnet_group"