Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

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

Copy
{ "Type" : "AWS::Batch::JobDefinition", "Properties" : { "Type" : String, "Parameters" : Json object, "ContainerProperties" : ContainerProperties, "JobDefinitionName" : String, "RetryStrategy" : RetryStrategy } }

YAML

Copy
Type: "AWS::Batch::JobDefinition" Properties: Type: String Parameters: Json object ContainerProperties: ContainerProperties JobDefinitionName: String RetryStrategy: RetryStrategy

Properties

Type

The type of job definition.

Required: yes

Type: String

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.

Required: yes

Type: JSON object

Update requires: No Interruption

JobDefinitionName

The name of the job definition.

Required: no

Type: String

Update requires: Replacement

ContainerProperties

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

Required: yes

Type: AWS Batch JobDefinition ContainerProperties

Update requires: No Interruption

RetryStrategy

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

Required: no

Type: AWS Batch JobDefinition RetryStrategy

Update requires: No Interruption

Return Values

Ref

When you pass the logical ID of an AWS::Batch::JobDefinition resource to the intrinsic Ref function, the function 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

Copy
{ "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

Copy
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