amazon-web-services - Cloudformation AWS::EC2::Security Group Vpc Id 需要一个字符串吗?

标签 amazon-web-services aws-cloudformation

我正在尝试编写一个云形成模板,为负载均衡器设置安全组。我可以通过以下方式为安全组选择 VPC:

"Parameters" : {
  "VpcId" : {
    "Description" : "VPC associated with the provided subnets",
    "Type" : "List<AWS::EC2::VPC::Id>"
  },
},

然后创建负载均衡器安全组:

"LbSecurityGroup" : {
  "Type" : "AWS::EC2::SecurityGroup",
  "Properties" : {
    "GroupDescription" : "Stack LBs",
    "VpcId" : { "Ref" : "VpcId" }
  }
},

当我启动堆栈时,它失败了:

CREATE_FAILED   AWS::EC2::SecurityGroup LbSecurityGroup
Value of property VpcId must be of type String

首先,为什么 AWS::EC2::SecurityGroup.VpcId 不是 AWS::EC2::VPC::Id 类型?其次,我如何将其按摩成一根绳子?

提前致谢!

最佳答案

额外的、更具体的类型(例如 AWS::EC2::SecurityGroup 而不仅仅是 String)是新的,并且仅用于参数 - 目的是在尝试创建堆栈之前验证资源是否存在。请参阅Using the New CloudFormation Parameter Types了解更多信息。

在您的情况下,我认为问题在于 VpcId 参数的类型是 AWS::EC2::SecurityGroup 值的列表,而不是单个值AWS::EC2::SecurityGroup 值? AWS::EC2::SecurityGroup 资源的 VpcId 属性仅采用单个字符串,而不是字符串列表 - 请参阅 VpcId .

关于amazon-web-services - Cloudformation AWS::EC2::Security Group Vpc Id 需要一个字符串吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29810122/

相关文章:

amazon-web-services - 如何使 S3 对象只能从某些 IP 地址读取?

hadoop - Hive - 指向同一个元存储的多个集群

amazon-web-services - 如何将 AWS CloudFormation 模板与简单系统管理和 ElasticBeanstalk 结合使用

amazon-web-services - AWS Codepipeline 和 Cloudformation 中的版本更改集

python - 从本地 python 脚本运行 AWS cli 命令?

amazon-web-services - AWS CloudFormation Fn::Join - 转义单引号

amazon-web-services - 如何防止角色与没有特定标签的 EC2 关联?

amazon-web-services - 云形成 : Block deleting resources

Linux 命令行搜索和替换

amazon-web-services - 当 AWS 节点组没有出现在 CloudFormation 中并且仅在尝试删除父集群或创建新集群时似乎存在时,如何销毁 AWS 节点组?