Created
December 9, 2017 10:44
-
-
Save li0nel/bb0e4607ac371c2a7fb7f6498bed50c1 to your computer and use it in GitHub Desktop.
CloudFormation stack for security-groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This security group defines who/where is allowed to access the ECS hosts directly. | |
# By default we're just allowing access from the load balancer. If you want to SSH | |
# into the hosts, or expose non-load balanced services you can open their ports here. | |
ECSSecurityGroup: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
VpcId: !Ref VPC | |
GroupDescription: Access to the ECS hosts and the tasks/containers that run on them | |
SecurityGroupIngress: | |
# Only allow inbound access to ECS from the ELB | |
- SourceSecurityGroupId: !Ref LoadBalancerSecurityGroup | |
IpProtocol: -1 | |
- IpProtocol: tcp | |
CidrIp: 0.0.0.0/0 | |
FromPort: '22' | |
ToPort: '22' | |
Tags: | |
- Key: Name | |
Value: !Sub ${EnvironmentName}-ECS-Hosts | |
# This security group defines who/where is allowed to access the Application Load Balancer. | |
# By default, we've opened this up to the public internet (0.0.0.0/0) but can you restrict | |
# it further if you want. | |
LoadBalancerSecurityGroup: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
VpcId: !Ref VPC | |
GroupDescription: Access to the load balancer that sits in front of ECS | |
SecurityGroupIngress: | |
# Allow access from anywhere to our ECS services | |
- CidrIp: 0.0.0.0/0 | |
IpProtocol: -1 | |
Tags: | |
- Key: Name | |
Value: !Sub ${EnvironmentName}-LoadBalancers | |
DBSecurityGroup: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
GroupDescription: Open database for access | |
VpcId: !Ref VPC | |
SecurityGroupIngress: | |
- IpProtocol: tcp | |
FromPort: '3306' | |
ToPort: '3306' | |
SourceSecurityGroupId: !Ref ECSSecurityGroup | |
Tags: | |
- Key: Name | |
Value: !Sub ${EnvironmentName}-DB-Host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment