微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

AWS CloudFormation 属性验证失败:[在 {/ContainerProperties/Environment 中遇到不受支持的属性

如何解决AWS CloudFormation 属性验证失败:[在 {/ContainerProperties/Environment 中遇到不受支持的属性

我正在使用 AWS Batch 创建 POC。为了创建基础设施,我使用了 AWS CloudFormation。

我对资源 AWS::Batch::JobDeFinition

有问题
  ContentInputJob:
    Type: "AWS::Batch::JobDeFinition"
    Properties:
      Type: Container
      ContainerProperties: 
        Environment:
          - name: SECRETS
            value: '**********'
        Command: 
          - -v
          - process
          - new-file
          - -o
        Image: !Join ['',[!Ref 'AWS::AccountId','.dkr.ecr.',!Ref 'AWS::Region','.amazonaws.com/',!Ref ImageName ] ]
        JobroleArn: !Ref BatchContainerIAMRole
        Memory: 128 
        Vcpus: 2
      JobDeFinitionName: DemoContentInput
      RetryStrategy: 
        Attempts: 1

创建堆栈失败,并显示...“属性验证失败:[在 {/ContainerProperties/Environment/0} 中遇到不受支持属性:[名称,值]]”

我读过:

我也试过这个:

  ContentInputJob:
    Type: "AWS::Batch::JobDeFinition"
    Properties:
      Type: Container
      ContainerProperties: 
        Environment:
          - SECRETS: '**********'
        Command: 
          - -v
          - process
          - new-file
          - -o
        Image: !Join ['',!Ref ImageName ] ]
        JobroleArn: !Ref BatchContainerIAMRole
        Memory: 128 
        Vcpus: 2
      JobDeFinitionName: DemoContentInput
      RetryStrategy: 
        Attempts: 1

然后我得到“属性验证失败:[在 {/ContainerProperties/Environment/0} 中遇到不受支持属性:[SECRETS]]”

它的语法如何?我需要多个环境变量。

      ContainerProperties: 
        Environment:
          - name: SECRETS
            value: '**********'
          - name: SECRETS2
            value: '**********'

解决方法

解决方案是使用大写字母。

      ContainerProperties: 
        Environment:
          - Name: SECRETS
            Value: '**********'
          - Name: SECRETS2
            Value: '**********'
,

建议尝试使用 CloudFormation Linter 中的 VSCode 在创作模板以及自动完成和文档链接时内联查看其中一些错误:

Visual Studio Code extension

[cfn-lint] E3002: Invalid Property Resources/ContentInputJob/Properties/ContainerProperties/Environment/0/name
[cfn-lint] E3002: Invalid Property Resources/ContentInputJob/Properties/ContainerProperties/Environment/0/value

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。