AWS::Batch::JobDefinition - AWS CloudFormation

AWS::Batch::JobDefinition

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.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::Batch::JobDefinition", "Properties" : { "ContainerProperties" : ContainerProperties, "JobDefinitionName" : String, "NodeProperties" : NodeProperties, "Parameters" : Json, "PlatformCapabilities" : [ String, ... ], "PropagateTags" : Boolean, "RetryStrategy" : RetryStrategy, "Tags" : Json, "Timeout" : Timeout, "Type" : String } }

Properties

ContainerProperties

An object with various properties specific to container-based jobs.

Required: No

Type: ContainerProperties

Update requires: No interruption

JobDefinitionName

The name of the job definition.

Required: No

Type: String

Update requires: Replacement

NodeProperties

An object with various properties specific to multi-node parallel jobs.

Note

If the job runs on Fargate resources, then you must not specify nodeProperties; use containerProperties instead.

Required: No

Type: NodeProperties

Update requires: No interruption

Parameters

Default parameters or parameter substitution placeholders that are set in the job definition. Parameters are specified as a key-value pair mapping. Parameters in a SubmitJob request override any corresponding parameter defaults from the job definition. For more information about specifying parameters, see Job Definition Parameters in the AWS Batch User Guide.

Required: No

Type: Json

Update requires: No interruption

PlatformCapabilities

The platform capabilities required by the job definition. If no value is specified, it defaults to EC2. Jobs run on Fargate resources specify FARGATE.

Required: No

Type: List of String

Update requires: No interruption

PropagateTags

Specifies whether to propagate the tags from the job or job definition to the corresponding Amazon ECS task. If no value is specified, the tags aren't propagated. Tags can only be propagated to the tasks during task creation. For tags with the same name, job tags are given priority over job definitions tags. If the total number of combined tags from the job and job definition is over 50, the job is moved to the FAILED state.

Required: No

Type: Boolean

Update requires: No interruption

RetryStrategy

The retry strategy to use for failed jobs that are submitted with this job definition.

Required: No

Type: RetryStrategy

Update requires: No interruption

Tags

The tags applied to the job definition.

Required: No

Type: Json

Update requires: Replacement

Timeout

The timeout configuration for jobs that are submitted with this job definition. You can specify a timeout duration after which AWS Batch terminates your jobs if they haven't finished.

Required: No

Type: Timeout

Update requires: No interruption

Type

The type of job definition. For more information about multi-node parallel jobs, see Creating a multi-node parallel job definition in the AWS Batch User Guide.

Note

If the job is run on Fargate resources, then multinode isn't supported.

Required: Yes

Type: String

Allowed values: container | multinode

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the job definition ARN, such as arn:aws:batch:us-east-1:111122223333:job-definition/test-gpu:2.

For more information about using the Ref function, see Ref.

Examples

Test nvidia-smi

The following example tests the nvidia-smi command on a GPU instance to verify that the GPU is working inside the container. For more information, see Test GPU Functionality in the AWS Batch User Guide.

JSON

{ "JobDefinition": { "Type": "AWS::Batch::JobDefinition", "Properties": { "Type": "container", "JobDefinitionName": "nvidia-smi", "ContainerProperties": { "MountPoints": [ { "ReadOnly": false, "SourceVolume": "nvidia", "ContainerPath": "/usr/local/nvidia" } ], "Volumes": [ { "Host": { "SourcePath": "/var/lib/nvidia-docker/volumes/nvidia_driver/latest" }, "Name": "nvidia" } ], "Command": [ "nvidia-smi" ], "Memory": 2000, "Privileged": true, "JobRoleArn": "String", "ReadonlyRootFilesystem": true, "Vcpus": 2, "Image": "nvidia/cuda" } } } }

YAML

JobDefinition: Type: AWS::Batch::JobDefinition Properties: Type: container JobDefinitionName: nvidia-smi ContainerProperties: MountPoints: - ReadOnly: false SourceVolume: nvidia ContainerPath: /usr/local/nvidia Volumes: - Host: SourcePath: /var/lib/nvidia-docker/volumes/nvidia_driver/latest Name: nvidia Command: - nvidia-smi Memory: 2000 Privileged: true JobRoleArn: String ReadonlyRootFilesystem: true Vcpus: 2 Image: nvidia/cuda

See also