Search code examples
yamlaws-cloudformation

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: '**********'

Solution

  • The solutions is use Capital letters.

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