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
resource "aws_batch_job_definition" "test_cpu" {
name = "jobTestCPU"
type = "container"
container_properties = templatefile("job-definitions/test-cpu.json.tmpl", {})
}
resource "aws_batch_job_definition" "jobA" {
name = "jobA"
type = "container"
container_properties = <<CONTAINER_PROPERTIES
{
"command": ["echo", "JobA"],
resource "aws_batch_job_definition" "container_properties_privileged_not_set" {
name = "foo"
type = "container"
container_properties = <<EOF
{
resource "aws_batch_job_definition" "container_properties_privileged_not_set" {
name = "foo"
type = "container"
container_properties = <<EOF
{
resource "aws_batch_job_definition" "container_properties_privileged_not_set" {
name = "foo"
type = "container"
container_properties = <<EOF
{
Parameters
-
arn
optional computed - string -
container_properties
optional - string -
id
optional computed - string -
name
required - string -
parameters
optional - map from string to string -
revision
optional computed - number -
tags
optional - map from string to string -
type
required - string -
retry_strategy
list block-
attempts
optional - number
-
-
timeout
list block-
attempt_duration_seconds
optional - number
-
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
Type: AWS::Batch::JobDefinition
Properties:
Type: container
ContainerProperties:
Memory: 512
Privileged: false
Type: AWS::Batch::JobDefinition
Properties:
Type: container
ContainerProperties:
Memory: 512
Privileged: false
Type: AWS::Batch::JobDefinition
Properties:
JobDefinitionName: "Isaac"
Type: container
RetryStrategy:
Attempts: 1
Type: AWS::Batch::JobDefinition
Properties:
JobDefinitionName: "Isaac"
Type: container
RetryStrategy:
Attempts: 1
Type: AWS::Batch::JobDefinition
Properties:
JobDefinitionName: "PreQC"
Type: container
RetryStrategy:
Attempts: 1
"Type": "AWS::Batch::JobDefinition",
"Properties": {
"Type": "container",
"JobDefinitionName": {"Ref" : "BatchPredictJobDefinitionName"},
"ContainerProperties": {
"Image": { "Ref": "ContainerRepoURI" },
"Type": "AWS::Batch::JobDefinition",
"Properties": {
"Type": "container",
"JobDefinitionName": "nvidia-smi",
"ContainerProperties": {
"Memory": 2000,
"Type": "AWS::Batch::JobDefinition"
}
}
}
"Type": "AWS::Batch::JobDefinition",
"Properties": {
"ContainerProperties": {
"Command": ["bash", "/${job}/${job}_setup.sh"],
"Image": "${account}/${job}:dev",
"JobRoleArn": {"Ref": "GeneralPurposeContainerRole"},
"Type": "AWS::Batch::JobDefinition"
},
"DataCarouselComputeEnvironment": {
"Properties": {
"ComputeResources": {
"DesiredvCpus": 1,
Parameters
-
Type
required - String -
Parameters
optional - Json -
NodeProperties
optional - NodeProperties -
SchedulingPriority
optional - Integer -
Timeout
optional - Timeout -
ContainerProperties
optional - ContainerProperties -
JobDefinitionName
optional - String -
PropagateTags
optional - Boolean -
PlatformCapabilities
optional - List -
RetryStrategy
optional - RetryStrategy -
Tags
optional - Json
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.