amazon-web-services - 向 AWS Cloudformation 中的安全组 Ingress 数组元素添加描述
问题描述
在 Cloudformation 中,是否可以像下面的示例一样添加安全组描述?
我在文档中看到(https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group-rule.html),但我从未见过 1 个带有描述的官方示例IP 规则,仅适用于GroupDescription
. 我发现这非常有用,因为它有助于识别 IP 所指的内容。那么,例如,这些示例片段是否有效?
"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable SSH access via port 22",
"SecurityGroupIngress" : [ {
"IpProtocol" : "tcp",
"FromPort" : 22,
"ToPort" : 22,
"CidrIp" : "0.0.0.0/0",
"Description" : "some description" <<<<<<<<<here
} ]
}
}
另一个例子
LoadBalancerSG:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: !Join ['-', [!Ref 'StackName', 'LoadBalancerSG']]
GroupDescription: Access to the load balancer
VpcId:
Fn::ImportValue: 'VpcID'
SecurityGroupIngress:
- IpProtocol: tcp
Description: 'this IP is ...' <<<<< here
CidrIp: 10.5.0.0/14
FromPort: '80'
ToPort: '80'
- IpProtocol: tcp
Description: 'this other IP is ...' <<<<<< here
CidrIp: 10.5.0.0/14
FromPort: '8080'
ToPort: '8080'
解决方案
"SecurityGroupIngress": [{
"IpProtocol": "tcp",
"CidrIp": "aa.xx.yy.zz/32",
"FromPort": "0000",
"ToPort": "0000"
}, {
"IpProtocol": "tcp",
"CidrIp": "bb.xx.yy.zz/32",
"FromPort": "0000",
"ToPort": "0000"
}, {
"IpProtocol": "tcp",
"Description": "ELB-EC2",
"SourceSecurityGroupId": "sg-nnnnnnnnnnnnn",
"FromPort": "000",
"ToPort": "000"
}
],
出于安全目的,实际值已更改,但除此之外,这是一个工作模板
推荐阅读
- web-scraping - 刮 https://socialblade.com/
- angular - 无法在错误“无法确定类 TestComponent 的模块”中找到 TestComponent
- c# - Entity Framework Core悲观锁定行表Mysql
- excel - VBA循环遍历表格并将图表导出到每封电子邮件
- angular - 如何使用 mat-dialog 的 backgroundClick 关闭对话框并将更改的数据发送回父组件
- python - 安装 Python 包将下载、安装和删除其他包
- javascript - 使用 javascript 设置默认打印机 - 特别是打印到 PDF
- javascript - 如何在点击时更改 divIcon className?
- javascript - 在最新版本的 firefox (64) 中使用 javascript 获取时区信息的问题
- ios - 如何通过选择 UITableViewCell 来更改 TabBarController 中的 ViewController?