Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

yaml - AWS CloudFormation Property validation failure: [Encountered unsupported properties in {/ContainerProperties/Environment

I'm creating a POC with AWS Batch. To create the infra I'm ussing AWS CloudFormation.

I have a problem with the resource 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

Creating the stack fails with... "Property validation failure: [Encountered unsupported properties in {/ContainerProperties/Environment/0}: [name, value]]"

I read:

I tried this too:

  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

Then I get "Property validation failure: [Encountered unsupported properties in {/ContainerProperties/Environment/0}: [SECRETS]]"

How is the syntax for this? I need more than one environment variable.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The solutions is use Capital letters.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...