1
votes

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

2 Answers

1
votes

Recommend trying the CloudFormation Linter in VSCode to see some of these errors inline while authoring templates along with autocompletion and documentation links:

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
0
votes

The solutions is use Capital letters.

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