-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_rds.yml
97 lines (85 loc) · 2.17 KB
/
create_rds.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
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
AWSTemplateFormatVersion: "2010-09-09"
Description: create rds
#パラメータ
Parameters:
vpcid:
Type: AWS::EC2::VPC::Id
Description: Enter vpcid
subnetid1:
Type: AWS::EC2::Subnet::Id
Description: Enter RDS subnetid
subnetid2:
Type: AWS::EC2::Subnet::Id
Description: Enter RDS subnetid
rdssubnetgroupname:
Type: String
Description: Enter RDS subnet groupname
rdsdbname:
Type: String
Description: Enter RDS DBname
rdsusername:
Type: String
Description: Enter RDS username
AllowedPattern: '[a-zA-Z0-9]*'
rdspassword:
Type: String
Description: Enter RDS password
MinLength: '8'
MaxLength: '41'
AllowedPattern: '[a-zA-Z0-9]*'
#リソース
Resources:
lambdasecuritygroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: lambda-securitygroup
SecurityGroupEgress:
- IpProtocol: -1
FromPort: -1
ToPort: -1
CidrIp: 0.0.0.0/0
VpcId: !Ref vpcid
rdssecuritygroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: rds-securitygroup
SecurityGroupEgress:
- IpProtocol: -1
FromPort: -1
ToPort: -1
CidrIp: 0.0.0.0/0
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 3306
ToPort: 3306
SourceSecurityGroupId: !Ref lambdasecuritygroup
VpcId: !Ref vpcid
rdssubnetgroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: rdssubnetgroup
SubnetIds:
- !Ref subnetid1
- !Ref subnetid2
DBSubnetGroupName: !Ref rdssubnetgroupname
Tags:
- Key: Name
Value: rdssubnetgroup
rdsinstance:
Type: AWS::RDS::DBInstance
Properties:
AllocatedStorage: 20
DBInstanceClass: db.t2.micro
DBSubnetGroupName:
!Ref rdssubnetgroup
DBName: !Ref rdsdbname
Engine: mysql
EngineVersion: "5.7.34"
MasterUsername: !Ref rdsusername
MasterUserPassword: !Ref rdspassword
StorageType: gp2
Tags:
- Key: Name
Value: rdsinstance
VPCSecurityGroups:
- !Ref rdssecuritygroup