-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest-db.yaml
123 lines (104 loc) · 2.82 KB
/
test-db.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Description: >
Create DB Instance
Parameters:
Subnet1:
Type: AWS::EC2::Subnet::Id
Subnet2:
Type: AWS::EC2::Subnet::Id
VpcId:
Type: AWS::EC2::VPC::Id
VpcCIDR:
Type: String
SecurityGroup:
Type: String
DBName:
Default: botkit
Description: testdb database name
Type: String
MinLength: 1
MaxLength: 64
AllowedPattern: "[a-zA-Z][a-zA-Z0-9]*"
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
DBUsername:
Default: dbadmin
NoEcho: true
Description: testdb admin account username
Type: String
MinLength: 1
MaxLength: 16
AllowedPattern: "[a-zA-Z][a-zA-Z0-9]*"
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
DBPassword:
Default: password
NoEcho: true
Description: testdb admin account password
Type: String
MinLength: 6
MaxLength: 41
AllowedPattern: "[a-zA-Z0-9]*"
ConstraintDescription: must contain only alphanumeric characters.
DBClass:
Default: db.t2.micro
Description: Database instance class
Type: String
AllowedValues:
- db.t2.micro
- db.m1.small
- db.m1.large
- db.m1.xlarge
- db.m2.xlarge
- db.m2.2xlarge
- db.m2.4xlarge
ConstraintDescription: must select a valid database instance type.
DBAllocatedStorage:
Default: 16
Description: The size of the database (Gb)
Type: Number
MinValue: 5
MaxValue: 1024
ConstraintDescription: must be between 5 and 1024Gb.
Resources:
DBSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Frontend Access
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 5432
ToPort: 5432
SourceSecurityGroupId: !Ref SecurityGroup
- IpProtocol: tcp
FromPort: 5432
ToPort: 5432
CidrIp: !Ref VpcCIDR
DBParamGroup:
Type: AWS::RDS::DBParameterGroup
Properties:
Description: Database Parameter Group + pg_stat_statements
Family: postgres9.6
Parameters:
shared_preload_libraries: pg_stat_statements
DBSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription : DB Subnet
SubnetIds:
- !Ref Subnet1
- !Ref Subnet2
DBInstance:
Type: AWS::RDS::DBInstance
Properties:
DBName: !Ref DBName
AllocatedStorage: !Ref DBAllocatedStorage
DBInstanceClass: !Ref DBClass
Engine: postgres
MasterUsername: !Ref DBUsername
MasterUserPassword: !Ref DBPassword
DBSubnetGroupName: !Ref DBSubnetGroup
DBParameterGroupName: !Ref DBParamGroup
VPCSecurityGroups:
- !GetAtt DBSecurityGroup.GroupId
Outputs:
DBAddress:
Value: !GetAtt DBInstance.Endpoint.Address