AWS Batch Job Definition

This page shows how to write Terraform and CloudFormation for AWS Batch Job Definition and write them securely.

aws_batch_job_definition (Terraform)

The Job Definition in AWS Batch can be configured in Terraform with the resource name aws_batch_job_definition. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

batch.tf#L160
resource "aws_batch_job_definition" "test_cpu" {
  name = "jobTestCPU"
  type = "container"

  container_properties = templatefile("job-definitions/test-cpu.json.tmpl", {})
}
main.tf#L1
resource "aws_batch_job_definition" "jobA" {
  name                 = "jobA"
  type                 = "container"
  container_properties = <<CONTAINER_PROPERTIES
{
    "command": ["echo", "JobA"],
container_properties_privileged.tf#L2
resource "aws_batch_job_definition" "container_properties_privileged_not_set" {
  name = "foo"
  type = "container"

  container_properties = <<EOF
{
container_properties_privileged.tf#L2
resource "aws_batch_job_definition" "container_properties_privileged_not_set" {
  name = "foo"
  type = "container"

  container_properties = <<EOF
{
container_properties_privileged.tf#L2
resource "aws_batch_job_definition" "container_properties_privileged_not_set" {
  name = "foo"
  type = "container"

  container_properties = <<EOF
{

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Provides a Batch Job Definition resource.

AWS::Batch::JobDefinition (CloudFormation)

The JobDefinition in Batch can be configured in CloudFormation with the resource name AWS::Batch::JobDefinition. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

batch_jobdefinition_container_properties_priveleged_false_boolean.yml#L4
    Type: AWS::Batch::JobDefinition
    Properties:
      Type: container
      ContainerProperties:
        Memory: 512
        Privileged: false
batch_jobdefinition_container_properties_priveleged_false_boolean.yml#L4
    Type: AWS::Batch::JobDefinition
    Properties:
      Type: container
      ContainerProperties:
        Memory: 512
        Privileged: false
batch_jobs_template_cfn.yml#L19
    Type: AWS::Batch::JobDefinition
    Properties:
      JobDefinitionName: "Isaac"
      Type: container
      RetryStrategy:
        Attempts: 1
batch_jobs_template_cfn.yml#L19
    Type: AWS::Batch::JobDefinition
    Properties:
      JobDefinitionName: "Isaac"
      Type: container
      RetryStrategy:
        Attempts: 1
batch_jobs_template_cfn.yml#L19
    Type: AWS::Batch::JobDefinition
    Properties:
      JobDefinitionName: "PreQC"
      Type: container
      RetryStrategy:
        Attempts: 1
batch.json#L94
      "Type": "AWS::Batch::JobDefinition",
      "Properties": {
        "Type": "container",
        "JobDefinitionName": {"Ref" : "BatchPredictJobDefinitionName"},
        "ContainerProperties": {
          "Image": { "Ref": "ContainerRepoURI" },
positive2.json#L6
      "Type": "AWS::Batch::JobDefinition",
      "Properties": {
        "Type": "container",
        "JobDefinitionName": "nvidia-smi",
        "ContainerProperties": {
          "Memory": 2000,
negative3.json#L36
      "Type": "AWS::Batch::JobDefinition"
    }
  }
}
job_def_template.json#L2
  "Type": "AWS::Batch::JobDefinition",
  "Properties": {
    "ContainerProperties": {
      "Command": ["bash", "/${job}/${job}_setup.sh"],
      "Image": "${account}/${job}:dev",
      "JobRoleArn": {"Ref": "GeneralPurposeContainerRole"},
stack.json#L160
            "Type": "AWS::Batch::JobDefinition"
        },
        "DataCarouselComputeEnvironment": {
            "Properties": {
                "ComputeResources": {
                    "DesiredvCpus": 1,

Parameters

Explanation in CloudFormation Registry

The AWS::Batch::JobDefinition resource specifies the parameters for an AWS Batch job definition. For more information, see Job Definitions in the AWS Batch User Guide.

Frequently asked questions

What is AWS Batch Job Definition?

AWS Batch Job Definition is a resource for Batch of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Batch Job Definition?

For Terraform, the azavea/noaa-flood-mapping, hayata-yamamoto/sequential-aws-batch-job and stelligent/config-lint source code examples are useful. See the Terraform Example section for further details.

For CloudFormation, the stelligent/cfn_nag, gustcol/Canivete and aws-samples/aws-batch-genomics source code examples are useful. See the CloudFormation Example section for further details.