【问题标题】:cloudformation error - Value of property SubnetIds must be of type List of Stringcloudformation 错误 - 属性 SubnetIds 的值必须是字符串列表类型
【发布时间】:2020-03-25 23:32:37
【问题描述】:

当我运行 create-stack 时,创建弹性搜索域失败并出现此错误 - “属性 SubnetIds 的值必须是字符串列表类型” 这里是CF模板的sn-p...

Parameters:
  SubnetIds:
    Type: 'List<AWS::EC2::Subnet::Id>'
    Description: Select a VPC subnet to place the instance. Select Multiple Subnets for multi-AZ deployments

Resources:
  ElasticsearchDomain:
    Type: 'AWS::Elasticsearch::Domain'
    Properties:
      AccessPolicies:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            AWS: '*'
          Action:
          - 'es:ESHttp*'
          Resource: !Sub 'arn:aws:es:${AWS::Region}:${AWS::AccountId}:domain/${DomainName}/*'
      DomainName: !Ref 'DomainName'
      EBSOptions:
        EBSEnabled: !Ref EBSEnabled
        VolumeSize: !Ref EBSVolumeSize
        VolumeType: gp2
      ElasticsearchClusterConfig:
        DedicatedMasterCount: !If [HasDedicatedMasterNodes, !Ref DedicatedMasterCount, !Ref 'AWS::NoValue']
        DedicatedMasterEnabled: !If [HasDedicatedMasterNodes, true, false]
        DedicatedMasterType: !If [HasDedicatedMasterNodes, !Ref DedicatedMasterType, !Ref 'AWS::NoValue']
        InstanceCount: !Ref ClusterInstanceCount
        InstanceType: !Ref ClusterInstanceType
        ZoneAwarenessEnabled: !If [HasSingleClusterInstance, false, true]
      ElasticsearchVersion: !Ref ElasticsearchVersion
      EncryptionAtRestOptions: !If [HasKmsKey, {Enabled: true, KmsKeyId: !Ref KMSEncryptionKey}, !Ref 'AWS::NoValue']
      SnapshotOptions:
        AutomatedSnapshotStartHour: 0
      VPCOptions:
        SecurityGroupIds:
        - !Ref SecurityGroup
        SubnetIds:
        - !Ref SubnetIds

也尝试过这样的方法,但不起作用 -

        SubnetIds:
        - [!Ref SubnetIds]

【问题讨论】:

    标签: amazon-cloudformation


    【解决方案1】:

    尝试使用以下代码 sn -p :

      VPCOptions:
        SubnetIds: !Ref ESSubnetsID
        SecurityGroupIds: !Ref ESSecurityGroup
    

    并使用以下内容更新参数部分:

      ESSubnetsID:
        Description: Choose which subnets the Elasticsearch cluster should use
        Type: 'List<AWS::EC2::Subnet::Id>'
        Default: 'subnet-1,subnet-2'
      ESSecurityGroup:
        Description: Select the SecurityGroup to use for the Elasticsearch cluster
        Type: 'List<AWS::EC2::SecurityGroup::Id>'
        Default: 'sg-1,sg-2'
    

    确保您传递子网 ID 列表

    【讨论】:

      【解决方案2】:

      就像错误消息所说,SubnetIds 应该是字符串列表,而不是您在 params 部分中定义的 List&lt;AWS::EC2::Subnet::Id&gt;。将其正确地重新定义为List&lt;String&gt;,它将起作用。

      Parameters:
        SubnetIds:
          Type: 'List<String>'
      

      【讨论】:

      • 一般来说你是对的,子网 id 必须是一个字符串列表。但是,您仍然可以使用 List&lt;AWS::EC2::Subnet::Id&gt; 类型,因为它是一个字符串数组。好处是当您创建堆栈时,您可以从下拉列表中选择子网,这有助于在开始创建或更新堆栈时捕获无效值。 docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/…
      猜你喜欢
      • 2021-12-05
      • 1970-01-01
      • 2020-07-14
      • 2020-11-06
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 1970-01-01
      • 2018-08-01
      相关资源
      最近更新 更多