공부/IaC
[AWS CloudFormation] Security Group Ingress 예제 (YAML)
haejang
2021. 6. 14. 15:17
728x90
728x90
참고로 Egress(OutBound)는 설정 안하면 0.0.0.0/0에 ALL로 열려있는게 Default다
1. ICMP 허용
Resources:
[SG 리소스 이름]:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow ICMP
GroupName: [SG 이름]
SecurityGroupIngress:
- IpProtocol: icmp
FromPort: -1
ToPort: -1
CidrIp: [허용할 IP/bit]
VpcId: !Ref [VPC 리소스 이름]
2. 모든 TCP 트래픽 허용
Resources:
[SG 리소스 이름]:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow TCP ALL
GroupName: [SG 이름]
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 0
ToPort: 65535
CidrIp: [허용할 IP/bit]
VpcId: !Ref [VPC 리소스 이름]
3. 모든 트래픽 허용
Resources:
[SG 리소스 이름]:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow ALL Traffic
GroupName: [SG 이름]
SecurityGroupIngress:
- IpProtocol: -1
CidrIp: [허용할 IP/bit]
VpcId: !Ref [VPC 리소스 이름]
4. IP가 아닌 보안그룹 ID로 제어 (3번 예제 변형)
Resources:
[SG 리소스 이름]:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow ALL Traffic
GroupName: [SG 이름]
SecurityGroupIngress:
- IpProtocol: -1
SourceSecurityGroupId : !Ref [허용할 SG 리소스 이름]
VpcId: !Ref [VPC 리소스 이름]
끝
728x90
728x90