This is the new AWS CloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see the AWS CloudFormation User Guide.
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" : { "ConsumableResourceProperties" :ConsumableResourceProperties, "ContainerProperties" :ContainerProperties, "EcsProperties" :EcsProperties, "EksProperties" :EksProperties, "JobDefinitionName" :String, "NodeProperties" :NodeProperties, "Parameters" :{, "PlatformCapabilities" :Key:Value, ...}[ String, ... ], "PropagateTags" :Boolean, "RetryStrategy" :RetryStrategy, "SchedulingPriority" :Integer, "Tags" :{, "Timeout" :Key:Value, ...}JobTimeout, "Type" :String} }
YAML
Type: AWS::Batch::JobDefinition Properties: ConsumableResourceProperties:ConsumableResourcePropertiesContainerProperties:ContainerPropertiesEcsProperties:EcsPropertiesEksProperties:EksPropertiesJobDefinitionName:StringNodeProperties:NodePropertiesParameters:PlatformCapabilities:Key:Value- StringPropagateTags:BooleanRetryStrategy:RetryStrategySchedulingPriority:IntegerTags:Timeout:Key:ValueJobTimeoutType:String
Properties
ConsumableResourceProperties-
Contains a list of consumable resources required by the job.
Required: No
Type: ConsumableResourceProperties
Update requires: No interruption
ContainerProperties-
An object with properties specific to Amazon ECS-based jobs. When
containerPropertiesis used in the job definition, it can't be used in addition toeksProperties,ecsProperties, ornodeProperties.Required: No
Type: ContainerProperties
Update requires: No interruption
EcsProperties-
An object that contains the properties for the Amazon ECS resources of a job.When
ecsPropertiesis used in the job definition, it can't be used in addition tocontainerProperties,eksProperties, ornodeProperties.Required: No
Type: EcsProperties
Update requires: No interruption
EksProperties-
An object with properties that are specific to Amazon EKS-based jobs. When
eksPropertiesis used in the job definition, it can't be used in addition tocontainerProperties,ecsProperties, ornodeProperties.Required: No
Type: EksProperties
Update requires: No interruption
JobDefinitionName-
The name of the job definition.
Required: No
Type: String
Maximum:
128Update requires: Replacement
NodeProperties-
An object with properties that are specific to multi-node parallel jobs. When
nodePropertiesis used in the job definition, it can't be used in addition tocontainerProperties,ecsProperties, oreksProperties.Note
If the job runs on Fargate resources, don't specify
nodeProperties. UsecontainerPropertiesinstead.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
SubmitJobrequest 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: Object of String
Pattern:
.*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 specifyFARGATE.Required: No
Type: Array of String
Update requires: No interruption
-
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 when the tasks are created. 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
FAILEDstate.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
SchedulingPriority-
The scheduling priority of the job definition. This only affects jobs in job queues with a fair-share policy. Jobs with a higher scheduling priority are scheduled before jobs with a lower scheduling priority.
Required: No
Type: Integer
Update requires: No interruption
-
The tags that are applied to the job definition.
Required: No
Type: Object of String
Pattern:
.*Update requires: Replacement
Timeout-
The timeout time for jobs that are submitted with this job definition. After the amount of time you specify passes, AWS Batch terminates your jobs if they aren't finished.
Required: No
Type: JobTimeout
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.
-
If the value is
container, then one of the following is required:containerProperties,ecsProperties, oreksProperties. -
If the value is
multinode, thennodePropertiesis required.
Note
If the job is run on Fargate resources, then
multinodeisn't supported.Required: Yes
Type: String
Allowed values:
container | multinodeUpdate 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.
Fn::GetAtt
The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.
JobDefinitionArn-
The job definition ARN, such as
arn:aws:batch:us-east-1:111122223333:job-definition/test-gpu:2.
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" ], "Privileged": true, "JobRoleArn": "String", "ReadonlyRootFilesystem": true, "ResourceRequirements": [ { "Type": "MEMORY", "Value": "2000" }, { "Type": "VCPU", "Value": "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 Privileged: true JobRoleArn: String ReadonlyRootFilesystem: true ResourceRequirements: - Type: MEMORY Value: '2000' - Type: VCPU Value: '2' Image: nvidia/cuda
See also
-
Job Definition Parameters in the AWS Batch User Guide .