Search code examples
amazon-web-servicesaws-cloudformationaws-batch

Cloudformation AWS::Batch::JobDefinition Property validation failure: [Encountered unsupported properties in {/}: [LogConfiguration]]


AWS CloudFormation UserGuide for AWS::Batch::JobDefinition says that there is LogConfiguration property. However when I try code bellow it gets error.

My CloudFormation code:

# AWS Batch Job Definition
  BatchProcessingJobDefinition:
    Type: AWS::Batch::JobDefinition
    Properties:
      Type: container
      JobDefinitionName: 
        Fn::Join:
        - ''
        - - !Ref 'AWS::StackName'
          - '-BatchJobDefinition'
      ContainerProperties:
        Image:
          Fn::Join:
          - ''
          - - Ref: AWS::AccountId
            - .dkr.ecr.
            - Ref: AWS::Region
            - '.amazonaws.com/'
            - 'batchjob-ecr'
            - ':latest'
        Vcpus: 2
        Memory: 2000
      LogConfiguration:
        LogDriver: "awslogs"
        Options: {
          "awslogs-region": "${MY_AWS_REGION}",
          "awslogs-group": "/aws/batch/custom/env-queue"
        }
      RetryStrategy:
        Attempts: 1

Property validation failure: [Encountered unsupported properties in {/}: [LogConfiguration]]


Solution

  • LogConfiguration is part of ContainerProperties. So it seems your indentation is incorrect:

      BatchProcessingJobDefinition:
        Type: AWS::Batch::JobDefinition
        Properties:
          Type: container
          JobDefinitionName: 
            Fn::Join:
            - ''
            - - !Ref 'AWS::StackName'
              - '-BatchJobDefinition'
          ContainerProperties:
            Image:
              Fn::Join:
              - ''
              - - Ref: AWS::AccountId
                - .dkr.ecr.
                - Ref: AWS::Region
                - '.amazonaws.com/'
                - 'batchjob-ecr'
                - ':latest'
            Vcpus: 2
            Memory: 2000
            LogConfiguration:
              LogDriver: "awslogs"
              Options: {
                "awslogs-region": "${MY_AWS_REGION}",
                "awslogs-group": "/aws/batch/custom/env-queue"
              }
          RetryStrategy:
            Attempts: 1