Skip to content

Instantly share code, notes, and snippets.

@daniyel
Created June 24, 2018 08:23
Show Gist options
  • Save daniyel/08f33d4c4d6065124c323c24c3df873c to your computer and use it in GitHub Desktop.
Save daniyel/08f33d4c4d6065124c323c24c3df873c to your computer and use it in GitHub Desktop.
Example of self-referencing security group in AWS
Parameters:
VPC:
Description: VPC that will be used for Cluster.
Type: AWS::EC2::VPC::Id
Resources:
MyTestSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId: !Ref VPC
GroupDescription: Just my testing security group.
Tags:
- Key: Name
Value: sg-mytest
MyTestSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
DependsOn: MyTestSecurityGroup
Properties:
Description: Allow access from anywhere to my security group.
GroupId: !Ref MyTestSecurityGroup
IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: '0.0.0.0/0'
MyTestSecurityGroupIngress2:
Type: AWS::EC2::SecurityGroupIngress
DependsOn: MyTestSecurityGroup
Properties:
GroupId: !Ref MyTestSecurityGroup
Description: Allow access between security groups.
IpProtocol: tcp
FromPort: '0'
ToPort: '65535'
SourceSecurityGroupId: !Ref MyTestSecurityGroup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment