Skip to content

Commit 76d4dbd

Browse files
authored
Restore Guardails Default Security Groups (#829)
1 parent 27e8680 commit 76d4dbd

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
AWSTemplateFormatVersion: 2010-09-09
2+
Description: Turbot required AWS Security groups for TEF 1.6.0+
3+
4+
Parameters:
5+
TurbotVpc:
6+
Description: VPC where Turbot is installed into.
7+
Type: "AWS::EC2::VPC::Id"
8+
9+
Resources:
10+
OutboundInternetSecurityGroup:
11+
Type: AWS::EC2::SecurityGroup
12+
Properties:
13+
GroupName: turbot_outbound_internet_security_group
14+
GroupDescription: Allow outbound HTTPS to the Internet.
15+
VpcId: !Ref TurbotVpc
16+
SecurityGroupEgress:
17+
- Description: Outbound HTTPS Internet access
18+
CidrIp: 0.0.0.0/0
19+
FromPort: 443
20+
ToPort: 443
21+
IpProtocol: tcp
22+
#
23+
# Without opening port 80, ECS optimised image will timeout:
24+
# Could not retrieve mirrorlist http://repo.ap-southeast-2.amazonaws.com/latest/main/mirror.list error was
25+
# 12: Timeout on http://repo.ap-southeast-2.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out
26+
# after 5000 milliseconds') Mar 05 00:12:33 cloud-init[2231]: util.py[WARNING]: Package upgrade failed
27+
#
28+
# The instance still boots OK but it's adding extra initialisation time
29+
#
30+
- Description: Outbound HTTP Internet access. Needed by cloud-init in ECS optimised image
31+
CidrIp: 0.0.0.0/0
32+
FromPort: 80
33+
ToPort: 80
34+
IpProtocol: tcp
35+
- Description: Outbound TCP DNS access.
36+
CidrIp: 0.0.0.0/0
37+
FromPort: 53
38+
ToPort: 53
39+
IpProtocol: tcp
40+
- Description: Outbound UDP DNS Access.
41+
CidrIp: 0.0.0.0/0
42+
FromPort: 53
43+
ToPort: 53
44+
IpProtocol: udp
45+
- Description: Outbound NTP access.
46+
CidrIp: 0.0.0.0/0
47+
FromPort: 123
48+
ToPort: 123
49+
IpProtocol: tcp
50+
51+
LoadBalancerSecurityGroup:
52+
Type: "AWS::EC2::SecurityGroup"
53+
Properties:
54+
GroupName: turbot_load_balancer_security_group
55+
GroupDescription: Load Balancer
56+
VpcId: !Ref TurbotVpc
57+
58+
ApiServiceSecurityGroup:
59+
Type: "AWS::EC2::SecurityGroup"
60+
Properties:
61+
GroupName: turbot_api_security_group
62+
GroupDescription: API Service
63+
VpcId: !Ref TurbotVpc
64+
SecurityGroupEgress:
65+
- Description: Loopback - required CloudFormation hack to avoid adding the default egress rule
66+
CidrIp: 127.0.0.1/32
67+
FromPort: 443
68+
ToPort: 443
69+
IpProtocol: tcp
70+
71+
LoadBalancerSgHttpsFromClients:
72+
Type: AWS::EC2::SecurityGroupIngress
73+
Properties:
74+
GroupId: !GetAtt LoadBalancerSecurityGroup.GroupId
75+
Description: HTTPS from Clients to LB
76+
CidrIp: 0.0.0.0/0
77+
IpProtocol: tcp
78+
FromPort: 443
79+
ToPort: 443
80+
81+
LoadBalancerSgHttpsToEcs:
82+
Type: AWS::EC2::SecurityGroupEgress
83+
Properties:
84+
GroupId: !GetAtt LoadBalancerSecurityGroup.GroupId
85+
Description: HTTPS from LB to ECS
86+
DestinationSecurityGroupId: !GetAtt ApiServiceSecurityGroup.GroupId
87+
IpProtocol: tcp
88+
# We've observed that target groups often open ports in the 32k range
89+
FromPort: 32768
90+
ToPort: 65535
91+
92+
ApiServiceSgHttpsFromLoadBalancer:
93+
Type: AWS::EC2::SecurityGroupIngress
94+
Properties:
95+
GroupId: !GetAtt ApiServiceSecurityGroup.GroupId
96+
Description: HTTPS from LB to API Containers
97+
SourceSecurityGroupId: !GetAtt LoadBalancerSecurityGroup.GroupId
98+
IpProtocol: tcp
99+
FromPort: 32768
100+
ToPort: 65535

0 commit comments

Comments
 (0)