amazon-web-services - aws cloudformation Elasticsearch 堆栈

标签 amazon-web-services elasticsearch yaml aws-cloudformation

我编写了以下模板来根据用户输入选择环境。但我收到错误“调用 CreateStack 操作时发生错误 (ValidationError):模板格式错误:[/Resources/Type] 资源定义格式错误”。请指导我需要更改哪些内容以及语法是否格式正确.

    AWSTemplateFormatVersion: 2010-09-09
      Parameters:
          EnvironmentValue:
             AllowedValues:
               - PROD
               - TEST
             Description: 'Please select an Environment'
             Type: String
      Mappings:
          Environment:
             PROD:
                VPC: vpc-xxxxxxxx
                Subnets: 'subnet-xxxxx,subnet-xxxxx,subnet-xxxx'
                Securitygroups: 'sg-xxxx,sg-xxxx'

             TEST:
                VPC: vpc-xxxxx
                Subnets: 'subnet-xxxx,subnet-xxxxx'
                Securitygroups: 'sg-xxxx,sg-xxxxx'
       #Conditions:
       #    CreatePRODStack: !Equals [!Ref EnvironmentValue, PROD]
       #    CreateTESTStack: !Equals [!Ref EnvironmentValue, TEST]
       Resources:
          Type: 'AWS::Es:Domain'
             Properties:
               DomainName: EPD34
               ElasticsearchVersion: 6.5
               ElasticsearchClusterConfig:
                   DedicatedMasterEnabled: 'true'
                   InstanceCount: '2'
                   ZoneAwarenessEnabled: 'true'
                   InstanceType: r4.xlarge.elasticsearch
                   DedicatedMasterType: r4.xlarge.elasticsearch
                   DedicatedMasterCount: '2'
               EBSOptions:
                   EBSEnabled: true
                   Iops: 0
                   VolumeSize: 100
                   VolumeType: gp2
               VPCOptions: !FindInMap [Environment, !Ref 'EnvironmentValue', VPC]
               SubnetIds: !FindInMap [Environment, !Ref 'EnvironmentValue', Subnets]
               Securitygroups: !FindInMap [Environment, !Ref 'EnvironmentValue', Securitygroups]
               SnapshotOptions:
                      AutomatedSnapshotStartHour: '0'
          Type: 'AWS::IAM::Policy'
              Properties: 
                  PolicyDocument: YAML
                  PolicyName: prodtest

当用户以 Prod 形式提供输入时,应在 Cloudformation 中创建 Prod 堆栈

最佳答案

我在这里看到一些问题:

1 - 您尚未命名您的资源。 2 - 你的缩进看起来不正确,这对 yaml 很重要 3 - 我认为您的 Elasticsearch 域类型不正确。你有

类型:'AWS::Es:Domain'

但我认为应该是

类型:AWS::Elasticsearch::Domain

以您的域为例,我认为它应该更符合以下内容:

ElasticsearchDomain:
    Type: AWS::Elasticsearch::Domain
    Properties:
        DomainName: EPD34
        ElasticsearchVersion: 6.5
        ElasticsearchClusterConfig:
            DedicatedMasterEnabled: 'true'
            InstanceCount: '2'
            ZoneAwarenessEnabled: 'true'
            InstanceType: r4.xlarge.elasticsearch
            DedicatedMasterType: r4.xlarge.elasticsearch
            DedicatedMasterCount: '2'
        EBSOptions:
            EBSEnabled: true
            Iops: 0
            VolumeSize: 100
            VolumeType: gp2
        VPCOptions: !FindInMap [Environment, !Ref 'EnvironmentValue', VPC]
        SubnetIds: !FindInMap [Environment, !Ref 'EnvironmentValue', Subnets]
        Securitygroups: !FindInMap [Environment, !Ref 'EnvironmentValue', Securitygroups]
        SnapshotOptions:
            AutomatedSnapshotStartHour: '0'

这里可能还有其他问题,但这里肯定存在语法错误

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html

关于amazon-web-services - aws cloudformation Elasticsearch 堆栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56159840/

相关文章:

python - AWS ElastiCache 描述 CacheClusters

linux - ElasticSearch 使用 IP 表限制访问

elasticsearch - Elasticsearch电子邮件的域聚合

json - 构面使用空格标记标记。有解决方案吗?

javascript - 亚马逊 Alexa 错误

ios - AWS SNS 异常错误

python - 指定 PyYAML 转储部分的样式(二): sequences

c# - 如何将自定义转换器应用于 YamlDotNet 中的属性

R read_yaml() 读取一个向量作为参数

javascript - Cognito 从预注册 Lambda 触发器发送什么样的事件