Friday, November 5, 2021

 

How to put Multiple Ingress/Egress Rules in SecurityGroup -  AWS::EC2::SecurityGroup

If you have to include multiple rules for a SecurityGroup then just add the required IpProtocol, see below example

SourceSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
VpcId: !Ref VpcId
GroupDescription: SG to allow SSH access via port 22, 443, 1500
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: '0.0.0.0/0'
- IpProtocol: tcp
FromPort: '443'
ToPort: '443'
CidrIp: '0.0.0.0/0'
- IpProtocol: tcp
FromPort: '1500'
ToPort: '1500'
CidrIp: '0.0.0.0/0'
Tags:
- Key: Name
Value: SG-SSHnADS-Ports-anyIP


If you have queries, do drop in your queries below.

...HaPpY CoDiNg
Partha