【问题标题】:AWS Cloudformation Value of property SubnetIds must be of type List of StringAWS Cloudformation 属性 SubnetIds 的值必须是字符串列表类型
【发布时间】:2021-12-05 16:43:59
【问题描述】:

我正在绑定这个 cloudformation 堆栈,但是当创建到达 DBSubnetGroup 时它失败并显示消息:属性 SubnetIds 的值必须是字符串列表类型。我感谢您的帮助。 除了 DBSubnetGroup 之外,一切似乎都运行良好。

AWSTemplateFormatVersion: 2010-09-09
Description: My First CloudFormation Template
Resources:
  MyVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.1.0.0/16
      EnableDnsHostnames: true
      EnableDnsSupport: true
      InstanceTenancy: default
      Tags:
      - Key: Name
        Value: VPC for Activity Number 1 
  MySubnet:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref MyVPC
      CidrBlock: 10.1.1.0/24
      MapPublicIpOnLaunch: true
      AvailabilityZone: "us-east-1c"
      Tags:
      - Key: Name
        Value: Public Subnet 
  MySubnetA:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref MyVPC
      CidrBlock: 10.1.2.0/24
      MapPublicIpOnLaunch: true
      AvailabilityZone: "us-east-1a"
      Tags:
      - Key: Name
        Value: Public Subnet  A
  MySubnetB:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref MyVPC
      CidrBlock: 10.1.3.0/24
      MapPublicIpOnLaunch: true
      AvailabilityZone: "us-east-1b"
      Tags:
      - Key: Name
        Value: Public Subnet B      

这就是创建失败开始的地方:

  DBSubnetGroup:
    Type: AWS::RDS::DBSubnetGroup
    DependsOn:
      - MyVPC
      - MySubnet
      - MySubnetA
      - MySubnetB
    Properties:
      DBSubnetGroupDescription: Subnets to lauch the database
      SubnetIds: 
        -!Ref MySubnet
        -!Ref MySubnetA  
        -!Ref MySubnetB    
        
      

【问题讨论】:

    标签: string amazon-web-services yaml amazon-cloudformation amazon-rds


    【解决方案1】:

    您应该在- 和内部函数!Ref 之间留一个空格,以便正确解析。遗憾的是,CloudFormation 仅在创建堆栈时检测到这一点。

     DBSubnetGroup:
        Type: AWS::RDS::DBSubnetGroup
        DependsOn:
          - MyVPC
          - MySubnet
          - MySubnetA
          - MySubnetB
        Properties:
          DBSubnetGroupDescription: Subnets to lauch the database
          SubnetIds: 
            - !Ref MySubnet
            - !Ref MySubnetA  
            - !Ref MySubnetB
    

    【讨论】:

    • 谢谢大家。问题已解决。
    • @FoudilGhelem 如果问题得到解决,那么应该接受答案。
    猜你喜欢
    • 2020-03-25
    • 1970-01-01
    • 2020-07-14
    • 2020-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-06
    • 2021-02-22
    相关资源
    最近更新 更多