0
votes

I am trying to create jobqueue template in which I declare output values so that jobqueue can be imported into other stacks.

Template:

{
"Resources": {
  "MyJobQueue": {
    "Type": "AWS::Batch::JobQueue",
    "Properties": {
      "ComputeEnvironmentOrder": [
        {
          "Order": 1,
          "ComputeEnvironment": "testcompenv"
        }
      ],
      "State": "ENABLED",
      "Priority": 1,
      "JobQueueName": "testjobqueue"
    }
  },
  "Outputs": {
        "TestOutputName": {
            "Description": "job queue arn",
            "Value": {
                "Ref": "MyJobQueue"
            },
            "Export": {
                "Name": {
                    "Fn::Sub": "${AWS::StackName}-MyJobQueueExport"
                }
            }
        }
    }

}
}

Error:

Template validation error: Invalid template resource property 'TestOutputName'

I am getting template validation error in the place of 'TestOutputName' can anyone tell what i should give here.

and In "Fn::Sub": "${AWS::StackName}-MyJobQueueExport"

MyJobQueueExport should be same as the stack name?

2

2 Answers

2
votes

You simply misplaced one closing bracket, causing Outputs to end up below Resources. Try this:

{
    "Resources": {
        "MyJobQueue": {
            "Properties": {
                "ComputeEnvironmentOrder": [
                    {
                        "ComputeEnvironment": "testcompenv",
                        "Order": 1
                    }
                ],
                "JobQueueName": "testjobqueue",
                "Priority": 1,
                "State": "ENABLED"
            },
            "Type": "AWS::Batch::JobQueue"
        }
    },
    "Outputs": {
        "TestOutputName": {
            "Description": "job queue arn",
            "Export": {
                "Name": {
                    "Fn::Sub": "${AWS::StackName}-MyJobQueueExport"
                }
            },
            "Value": {
                "Ref": "MyJobQueue"
            }
        }
    }
}
0
votes

I got this error:

Template validation error - Invalid template resource property 'prod'

In my Parameters section I accidentally included a Mapping:

EnvType:
    Description: Environment Name
    Default: test
    Type: String
    AllowedValues:  [dev, test, prod]
DisableTerminate:
    prod:
      YesorNo: 'true'
    test:
      YesorNo: 'false'
    dev:
      YesorNo: 'false'

Putting the DisableTerminate mapping in the correct section resolved the problem.