-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path01-database.yml
41 lines (38 loc) · 1.19 KB
/
01-database.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
Parameters:
AppName:
Type: String
DatabaseInstanceType:
Type: String
DatabaseAllocatedStorage:
Type: Number
DatabaseSG:
Type: AWS::EC2::SecurityGroup::Id
Subnets:
Type: List<AWS::EC2::Subnet::Id>
SecretArn:
Type: String
Resources:
DatabaseSubnet:
Type: "AWS::RDS::DBSubnetGroup"
Properties:
DBSubnetGroupDescription: !Sub ${AWS::StackName} RDS Subnet
SubnetIds: !Ref Subnets
RDS:
Type: "AWS::RDS::DBInstance"
Properties:
StorageType: gp2
AllocatedStorage: !Ref DatabaseAllocatedStorage
DBInstanceClass: !Ref DatabaseInstanceType
Engine: "mysql"
EngineVersion: "5.7.19"
MasterUsername: !Join ['', ['{{resolve:secretsmanager:', !Ref SecretArn, ':SecretString:username}}' ]]
MasterUserPassword: !Join ['', ['{{resolve:secretsmanager:', !Ref SecretArn, ':SecretString:password}}' ]]
DBSubnetGroupName: !Ref DatabaseSubnet
VPCSecurityGroups:
- !Ref DatabaseSG
SecretRDSAttachment:
Type: "AWS::SecretsManager::SecretTargetAttachment"
Properties:
SecretId: !Ref SecretArn
TargetId: !Ref RDS
TargetType: AWS::RDS::DBInstance