-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path06-01-RDS.yaml
100 lines (100 loc) · 2.95 KB
/
06-01-RDS.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
Parameters:
VPCId:
Type: AWS::EC2::VPC::Id
Description: VPC where DB will launch
SubnetIds:
Type: List<AWS::EC2::Subnet::Id>
Description: Subnets where the DB will launch (pick at least 2)
SecurityGroupAllowCidr:
Type: String
Description: Allow this CIDR block to access the DB
Default: "172.30.0.0/16"
DBUsername:
Type: String
Description: Username to access the database
MinLength: 1
AllowedPattern: "[a-zA-Z][a-zA-Z0-9]*"
ConstraintDescription: must start with a letter, must
be alphanumeric
DBPassword:
Type: String
Description: Password to access the database
MinLength: 1
AllowedPattern: "[a-zA-Z0-9]*"
NoEcho: true
ConstraintDescription: must be alphanumeric
DBInstanceClass:
Type: String
Description: The instance type to use for this database
Default: db.t2.micro
DBStorageAmount:
Type: Number
Description: Amount of storage to allocate (in GB)
Default: 10
DBStorageType:
Type: String
Description: Type of storage volume to use
(standard [magnetic] or gp2)
Default: standard
AllowedValues:
- standard
- gp2
DBEngineVersion:
Type: String
Description: DB engine version
Default: "5.7.11"
DBPort:
Type: Number
Description: Port number to allocate
Default: 3306
MinValue: 1150
MaxValue: 65535
DBMultiAZ:
Type: String
Description: Should this DB be deployed in Multi-AZ configuration?
Default: true
AllowedValues:
- true
- false
DBBackupRetentionPeriod:
Type: Number
Description: How many days to keep backups (0 disables backups)
Default: 1
MinValue: 0
MaxValue: 35
Resources:
ExampleDBSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Example security group for inbound access to DB
SecurityGroupIngress:
- IpProtocol: tcp
CidrIp: !Ref SecurityGroupAllowCidr
FromPort: !Ref DBPort
ToPort: !Ref DBPort
VpcId: !Ref VPCId
ExampleDBSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: Example subnet group for example DB
SubnetIds:
- Fn::Select: [ 0, Ref: SubnetIds ]
- Fn::Select: [ 1, Ref: SubnetIds ]
ExampleDBInstance:
Type: AWS::RDS::DBInstance
Properties:
AllocatedStorage: !Ref DBStorageAmount
BackupRetentionPeriod: !Ref DBBackupRetentionPeriod
DBInstanceClass: !Ref DBInstanceClass
DBSubnetGroupName: !Ref ExampleDBSubnetGroup
Engine: mysql
EngineVersion: !Ref DBEngineVersion
MasterUsername: !Ref DBUsername
MasterUserPassword: !Ref DBPassword
MultiAZ: !Ref DBMultiAZ
StorageType: !Ref DBStorageType
VPCSecurityGroups:
- !GetAtt ExampleDBSecurityGroup.GroupId
Outputs:
ExampleDbHostname:
Value: !GetAtt ExampleDBInstance.Endpoint.Address