Skip to content

Commit 2100228

Browse files
committed
Restrict instance security group to traffic from load balancer.
1 parent 673a6cc commit 2100228

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

cloudformation.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@
9393
"RouteTableId": { "Ref": "PublicRouteTable" }
9494
}
9595
},
96-
"InstanceSecurityGroup": {
96+
"ALBSecurityGroup": {
9797
"Type": "AWS::EC2::SecurityGroup",
9898
"Properties": {
9999
"VpcId": { "Ref": "VPC" },
100-
"GroupDescription": "Allow inbound traffic",
100+
"GroupDescription": "Allow inbound HTTP from anywhere",
101101
"SecurityGroupIngress": [
102102
{
103103
"IpProtocol": "tcp",
@@ -107,28 +107,31 @@
107107
}
108108
],
109109
"SecurityGroupEgress": [
110-
{
110+
{
111111
"IpProtocol": "-1",
112112
"CidrIp": "0.0.0.0/0"
113113
}
114114
]
115115
}
116116
},
117-
"ALBSecurityGroup": {
117+
"InstanceSecurityGroup": {
118118
"Type": "AWS::EC2::SecurityGroup",
119119
"Properties": {
120120
"VpcId": { "Ref": "VPC" },
121-
"GroupDescription": "Allow inbound HTTP from anywhere",
121+
"GroupDescription": "Allow inbound traffic from application load balancer",
122122
"SecurityGroupIngress": [
123123
{
124124
"IpProtocol": "tcp",
125125
"FromPort": 80,
126126
"ToPort": 80,
127-
"CidrIp": "0.0.0.0/0"
127+
"SourceSecurityGroupId": { "Ref": "ALBSecurityGroup" }
128128
}
129129
],
130130
"SecurityGroupEgress": [
131-
{ "IpProtocol": "-1", "CidrIp": "0.0.0.0/0" }
131+
{
132+
"IpProtocol": "-1",
133+
"CidrIp": "0.0.0.0/0"
134+
}
132135
]
133136
}
134137
},

0 commit comments

Comments
 (0)