/
1st security feedback.yaml
192 lines (174 loc) · 4.65 KB
/
1st security feedback.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
AWSTemplateFormatVersion: "2010-09-09"
Metadata:
Generator: "former2"
Description: "CFn Template for Former2 Test"
Parameters:
AllowedCIDR:
Type: String
Description: Allowed IP range for SSH and HTTP access
Resources:
EC2SecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "EC2 Security Group"
VpcId: !Ref EC2VPC
SecurityGroupIngress:
- CidrIp: !Ref AllowedCIDR
FromPort: 22
ToPort: 22
IpProtocol: "tcp"
- CidrIp: !Ref AllowedCIDR
FromPort: 80
ToPort: 80
IpProtocol: "tcp"
SecurityGroupEgress:
- CidrIp: !Ref AllowedCIDR
IpProtocol: "-1"
RDSSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "RDS Security Group"
VpcId: !Ref EC2VPC
SecurityGroupIngress:
- SourceSecurityGroupId: !Ref EC2SecurityGroup
FromPort: 3306
ToPort: 3306
IpProtocol: "tcp"
SecurityGroupEgress:
- CidrIp: !Ref AllowedCIDR
IpProtocol: "-1"
EC2VPC:
Type: "AWS::EC2::VPC"
Properties:
CidrBlock: "10.0.0.0/16"
EnableDnsHostnames: true
EnableDnsSupport: true
InstanceTenancy: "default"
Tags:
- Key: "prj"
Value: "former"
EC2Subnet:
Type: "AWS::EC2::Subnet"
Properties:
AvailabilityZone: "ap-northeast-1a"
CidrBlock: "10.0.1.0/24"
MapPublicIpOnLaunch: false
VpcId: !Ref EC2VPC
Tags:
- Key: "prj"
Value: "former"
EC2Subnet2:
Type: "AWS::EC2::Subnet"
Properties:
AvailabilityZone: "ap-northeast-1c"
CidrBlock: "10.0.2.0/24"
MapPublicIpOnLaunch: false
VpcId: !Ref EC2VPC
Tags:
- Key: "prj"
Value: "former"
EC2InternetGateway:
Type: "AWS::EC2::InternetGateway"
Properties:
Tags:
- Key: "prj"
Value: "former"
EC2VPCGatewayAttachment:
Type: "AWS::EC2::VPCGatewayAttachment"
Properties:
VpcId: !Ref EC2VPC
InternetGatewayId: !Ref EC2InternetGateway
EC2RouteTable:
Type: "AWS::EC2::RouteTable"
Properties:
VpcId: !Ref EC2VPC
Tags:
- Key: "prj"
Value: "former"
EC2RouteTable2:
Type: "AWS::EC2::RouteTable"
Properties:
VpcId: !Ref EC2VPC
Tags:
- Key: "prj"
Value: "former"
EC2SubnetRouteTableAssociation:
Type: "AWS::EC2::SubnetRouteTableAssociation"
Properties:
RouteTableId: !Ref EC2RouteTable
SubnetId: !Ref EC2Subnet
EC2SubnetRouteTableAssociation2:
Type: "AWS::EC2::SubnetRouteTableAssociation"
Properties:
RouteTableId: !Ref EC2RouteTable2
SubnetId: !Ref EC2Subnet2
EC2InternetRoute:
Type: "AWS::EC2::Route"
DependsOn: EC2VPCGatewayAttachment
Properties:
DestinationCidrBlock: "0.0.0.0/0"
GatewayId: !Ref EC2InternetGateway
RouteTableId: !Ref EC2RouteTable
EC2InternetRoute2:
Type: "AWS::EC2::Route"
DependsOn: EC2VPCGatewayAttachment
Properties:
DestinationCidrBlock: "0.0.0.0/0"
GatewayId: !Ref EC2InternetGateway
RouteTableId: !Ref EC2RouteTable2
EC2Instance:
Type: "AWS::EC2::Instance"
Properties:
InstanceType: "t2.micro"
SubnetId: !Ref EC2Subnet
ImageId: "ami-0123456789abcdef0" # Replace with desired AMI ID
SecurityGroupIds:
- !Ref EC2SecurityGroup
Tags:
- Key: "prj"
Value: "former"
EC2Instance2:
Type: "AWS::EC2::Instance"
Properties:
InstanceType: "t2.micro"
SubnetId: !Ref EC2Subnet2
ImageId: "ami-0123456789abcdef0" # Replace with desired AMI ID
SecurityGroupIds:
- !Ref EC2SecurityGroup
Tags:
- Key: "prj"
Value: "former"
RDSDBSubnetGroup:
Type: "AWS::RDS::DBSubnetGroup"
Properties:
DBSubnetGroupDescription: "RDS DB Subnet Group"
SubnetIds:
- !Ref EC2Subnet
- !Ref EC2Subnet2
Tags:
- Key: "prj"
Value: "former"
RDSDBInstance:
Type: "AWS::RDS::DBInstance"
Properties:
AllocatedStorage: 20
BackupRetentionPeriod: 7
DBInstanceClass: "db.t2.micro"
DBInstanceIdentifier: "mydbinstance"
Engine: "MySQL"
EngineVersion: "5.7"
MasterUsername: "admin"
MasterUserPassword: "password123"
DBSubnetGroupName: !Ref RDSDBSubnetGroup
VPCSecurityGroups:
- !Ref RDSSecurityGroup
Tags:
- Key: "prj"
Value: "former"
Outputs:
EC2Instance1IP:
Value: !Ref EC2Instance
EC2Instance2IP:
Value: !Ref EC2Instance2
RDSDBEndpoint:
Value: !GetAtt RDSDBInstance.Endpoint.Address