amazon-web-services - AWS CloudFormation VPC CIDR 分配给安全组
问题描述
当我选择 VPC 网络时,如何将 VPC 的 CIDR 分配给安全组?
Parameters:
VpcId:
Type: 'AWS::EC2::VPC::Id'
Description: VpcId of your existing Virtual Private Cloud (VPC)
ConstraintDescription: must be the VPC Id of an existing Virtual Private Cloud.
EC2SecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
VpcId: !Ref VpcId
GroupDescription: SecurityGroup
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp:
感谢您的帮助。
解决方案
您无法根据作为参数传递的 Id 获取 VPC CIDR 范围。您要么必须将CIDR 作为第二个参数传递,要么构建一个自定义资源来为您执行此操作。
自定义资源将是一个lambda 函数,它将 VPC id 作为输入参数。然后使用 AWS SDK,该函数将查询 VPC 并将其 CIDR 返回到您的 CloudFormation 以在您的安全组中使用。
推荐阅读
- php - 为什么 Bref 无法加载引导程序:“错误:找不到有效的引导程序:[/var/task/bootstrap /opt/bootstrap]”?
- c# - 在列表 C# 中有列表时从数据集中填充对象
- python - 使用 sympy 解析字符串时出现意外行为
- python - 使用 python 发送请求
- python - Channels:如何在 Windows Server 上使用 Redis 通道层作为后端来处理大量并发用户?
- javascript - React-Redux:接收和发送表单数据(服务器)
- css - :before 上的多行链接动画
- reactjs - 在 BotFramework WebChat 中压缩 botframework 文件上传图像?
- c# - Xamarin Forms (C#) - 从 Picker.SelectedIndexChanged 调用 Navigation.PushModalAsync 会引发空引用异常
- python - 如何在使用 SimpleITK 保存 DICOM 文件时保留 UID?