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
-
arnoptional computed - string -
container_propertiesoptional - string -
idoptional computed - string -
namerequired - string -
parametersoptional - map from string to string -
revisionoptional computed - number -
tagsoptional - map from string to string -
typerequired - string -
retry_strategylist block-
attemptsoptional - number
-
-
timeoutlist block-
attempt_duration_secondsoptional - 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
-
Typerequired - String -
Parametersoptional - Json -
NodePropertiesoptional - NodeProperties -
SchedulingPriorityoptional - Integer -
Timeoutoptional - Timeout -
ContainerPropertiesoptional - ContainerProperties -
JobDefinitionNameoptional - String -
PropagateTagsoptional - Boolean -
PlatformCapabilitiesoptional - List -
RetryStrategyoptional - RetryStrategy -
Tagsoptional - Json
Explanation in CloudFormation Registry
The
AWS::Batch::JobDefinitionresource 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.