【问题标题】:AWS CloudFormation Property validation failure: [Encountered unsupported properties in {/ContainerProperties/EnvironmentAWS CloudFormation 属性验证失败:[Encountered unsupported properties in {/ContainerProperties/Environment
【发布时间】:2021-04-16 04:53:08
【问题描述】:

我正在使用 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 '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} 中遇到不支持的属性:[SECRETS]]”

这个的语法是怎样的?我需要多个环境变量。

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

【问题讨论】:

    标签: yaml amazon-cloudformation


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢帕特,但我这个消息和我的一样。解决方案是使用大写字母。名称和价值
    • 属性自动完成会阻止它再次发生:)
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2020-06-03
      • 2021-12-06
      • 2021-05-31
      • 2019-11-02
      • 2019-04-23
      • 1970-01-01
      • 2020-09-20
      • 2020-08-17
      • 2012-05-31
      相关资源
      最近更新 更多