首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cloudformation属性SubnetIds的值必须是字符串类型列表

cloudformation属性SubnetIds的值必须是字符串类型列表
EN

Stack Overflow用户
提问于 2019-11-30 21:45:02
回答 2查看 13.1K关注 0票数 2

当我运行创建堆栈时,在创建elasticsearch域时出现了此错误--“属性值SubnetIds必须是字符串类型列表”这里是CF模板的片段.

代码语言:javascript
复制
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

我也试过这样做,但不管用-

代码语言:javascript
复制
        SubnetIds:
        - [!Ref SubnetIds]
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-11-30 22:44:11

尝试使用以下代码片段:

代码语言:javascript
复制
  VPCOptions:
    SubnetIds: !Ref ESSubnetsID
    SecurityGroupIds: !Ref ESSecurityGroup

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

代码语言:javascript
复制
  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'

确保您传递子网ids的List

票数 5
EN

Stack Overflow用户

发布于 2019-11-30 23:05:14

正如错误消息所述,SubnetIds应该是字符串列表,而不是在params部分中定义的List<AWS::EC2::Subnet::Id>。把它正确地定义为List<String>,它就能工作了。

代码语言:javascript
复制
Parameters:
  SubnetIds:
    Type: 'List<String>'
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59120539

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档