【问题标题】:aws cloudformation -resource property erroraws cloudformation - 资源属性错误
【发布时间】:2018-01-12 09:46:39
【问题描述】:

我已经这样定义了我的参数:

{
    "PrivateSubnets":{
       "Description":"db subnetlist",
       "Type": "List<AWS::EC2::Subnet::Id>"
    },

    "VPCLIST": {
       "Description": "VPC list",
       "Type": "List<AWS::EC2::VPC::Id>"
    }
}

并在“资源”部分引用上述参数,如下所示:

    "InstanceSecurityGroup" : {
      "Type" : "AWS::EC2::SecurityGroup",
      "Properties" : {
        "VpcId" : {"Ref": "VPCLIST"} ,
        "GroupDescription" : "Enable 3306/80/SSH access via port 22"
}

在执行此操作时,我收到以下错误。

AWS::EC2::SecurityGroup InstanceSecurityGroup "属性 VpcId 的值必须是字符串类型"

注意:我只有默认 VPC 可用,它不被视为字符串?这个问题的任何解决方案...

【问题讨论】:

  • 以下是错误消息:错误无法列出数据:内部故障

标签: amazon-cloudformation


【解决方案1】:

正确的方法是进行此更改:

{
  "PrivateSubnets": {
    "Description":"db subnetlist",
    "Type": "AWS::EC2::Subnet::Id"
  },
  "VPCLIST": {
    "Description": "VPC list",
    "Type": "AWS::EC2::VPC::Id"
  }
}

【讨论】:

    【解决方案2】:

    安全组要求VpcId为字符串,属性为数组列表,所以需要将属性改为Type:String,或者使用 Fn::Select 函数。

    { "Fn::Select" : [ 0, VPCLIST ] }
    

    列表 - VPC ID 数组

    {
      "Type" : "AWS::EC2::SecurityGroup",
      "Properties" : {
         "GroupName" : String,
         "GroupDescription" : String,
         "SecurityGroupEgress" : [ Security Group Rule, ... ],
         "SecurityGroupIngress" : [ Security Group Rule, ... ],
         "Tags" :  [ Resource Tag, ... ],
         "VpcId" : String
      }
    }
    

    http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html

    【讨论】:

      猜你喜欢
      • 2021-05-01
      • 2019-05-07
      • 2023-04-05
      • 1970-01-01
      • 2018-11-11
      • 1970-01-01
      • 2018-10-25
      • 2019-04-26
      • 2020-04-24
      相关资源
      最近更新 更多