![](/img/trans.png)
[英]CloudFormation - Assign a security group to a vpc dynamically based on a vpc tag value
[英]AWS CloudFormation VPC CIDR assign to Security Group
当我选择 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 开发工具包,该函数将查询 VPC 并将其 CIDR 返回到您的 CloudFormation 以在您的安全组中使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.