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 Vcpus: 2 Image: nvidia/cuda

Hello World

The following example creates an AWS Batch compute environment, job queue, and job definition for a simple "Hello World" batch job. When the job is submitted, it echoes "hello world" and exits. You can modify the job definition to run your own Docker container and/or batch scripts.

JSON

Copy
{ "Resources": { "SampleVPC": { "Type": "AWS::EC2::VPC", "Properties": { "CidrBlock": "10.0.0.0/16" } }, "SampleInternetGateway": { "Type": "AWS::EC2::InternetGateway", "DependsOn": "SampleVPC" }, "PublicRouteTable": { "Type": "AWS::EC2::RouteTable", "DependsOn": [ "SampleVPC", "SampleVPCGatewayAttachment" ], "Properties": { "VpcId": { "Ref": "SampleVPC" } } }, "SampleVPCGatewayAttachment": { "Type": "AWS::EC2::VPCGatewayAttachment", "DependsOn": [ "SampleVPC", "SampleInternetGateway" ], "Properties": { "VpcId": { "Ref": "SampleVPC" }, "InternetGatewayId": { "Ref": "SampleInternetGateway" } } }, "SampleSecurityGroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "GroupDescription": "A security group for region-agnostic CFNBatch Launchpad testing", "VpcId": { "Ref": "SampleVPC" } } }, "SampleSubnet": { "Type": "AWS::EC2::Subnet", "DependsOn": "SampleVPCGatewayAttachment", "Properties": { "CidrBlock": "10.0.0.0/24", "VpcId": { "Ref": "SampleVPC" }, "MapPublicIpOnLaunch": "True" } }, "PublicRoute": { "Type": "AWS::EC2::Route", "DependsOn": [ "PublicRouteTable", "SampleVPCGatewayAttachment" ], "Properties": { "RouteTableId": { "Ref": "PublicRouteTable" }, "DestinationCidrBlock": "0.0.0.0/0", "GatewayId": { "Ref": "SampleInternetGateway" } } }, "SampleSubnetRouteTableAssociation": { "Type": "AWS::EC2::SubnetRouteTableAssociation", "Properties": { "RouteTableId": { "Ref": "PublicRouteTable" }, "SubnetId": { "Ref": "SampleSubnet" } } }, "SampleAWSBatchServiceRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "batch.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AWSBatchServiceRole" ] } }, "SampleIamInstanceProfile": { "Type": "AWS::IAM::InstanceProfile", "Properties": { "Roles": [ { "Ref": "SampleEcsInstanceRole" } ] } }, "SampleEcsInstanceRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2008-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role" ] } }, "SampleJobDefinition": { "Type": "AWS::Batch::JobDefinition", "Properties": { "Type": "container", "ContainerProperties": { "Image": { "Fn::Join" : [ "", ["137112412989.dkr.ecr.", {"Ref": "AWS::Region"}, ".amazonaws.com/amazonlinux:latest" ]] }, "Vcpus": 2, "Memory": 2000, "Command": [ "echo", "'hello world'" ] }, "RetryStrategy": { "Attempts": 1 } } }, "SampleJobQueue": { "Type": "AWS::Batch::JobQueue", "DependsOn": [ "SampleComputeEnvironment" ], "Properties": { "Priority": 1, "ComputeEnvironmentOrder": [{ "Order": 1, "ComputeEnvironment": { "Ref": "SampleComputeEnvironment" } }] } }, "SampleComputeEnvironment": { "Type": "AWS::Batch::ComputeEnvironment", "DependsOn": [ "SampleSubnet", "SampleSecurityGroup", "SampleIamInstanceProfile", "SampleAWSBatchServiceRole" ], "Properties": { "Type": "MANAGED", "ComputeResources": { "Type": "EC2", "MinvCpus": 0, "DesiredvCpus": 0, "MaxvCpus": 64, "InstanceTypes": [ "optimal" ], "Subnets": [ { "Ref": "SampleSubnet" } ], "SecurityGroupIds": [ { "Ref": "SampleSecurityGroup" } ], "InstanceRole": { "Ref": "SampleIamInstanceProfile" } }, "ServiceRole": { "Ref": "SampleAWSBatchServiceRole" } } } }, "Outputs": { "SampleComputeEnvironmentArn": { "Value": { "Ref": "SampleComputeEnvironment" } }, "SampleJobQueueArn": { "Value": { "Ref": "SampleJobQueue" } }, "SampleJobDefinition": { "Value": { "Ref": "SampleJobDefinition" } } } }

YAML

Copy
Resources: SampleVPC: Type: 'AWS::EC2::VPC' Properties: CidrBlock: 10.0.0.0/16 SampleInternetGateway: Type: 'AWS::EC2::InternetGateway' DependsOn: SampleVPC PublicRouteTable: Type: 'AWS::EC2::RouteTable' DependsOn: - SampleVPC - SampleVPCGatewayAttachment Properties: VpcId: !Ref SampleVPC SampleVPCGatewayAttachment: Type: 'AWS::EC2::VPCGatewayAttachment' DependsOn: - SampleVPC - SampleInternetGateway Properties: VpcId: !Ref SampleVPC InternetGatewayId: !Ref SampleInternetGateway SampleSecurityGroup: Type: 'AWS::EC2::SecurityGroup' Properties: GroupDescription: A security group for region-agnostic CFNBatch Launchpad testing VpcId: !Ref SampleVPC SampleSubnet: Type: 'AWS::EC2::Subnet' DependsOn: SampleVPCGatewayAttachment Properties: CidrBlock: 10.0.0.0/24 VpcId: !Ref SampleVPC MapPublicIpOnLaunch: 'True' PublicRoute: Type: 'AWS::EC2::Route' DependsOn: - PublicRouteTable - SampleVPCGatewayAttachment Properties: RouteTableId: !Ref PublicRouteTable DestinationCidrBlock: 0.0.0.0/0 GatewayId: !Ref SampleInternetGateway SampleSubnetRouteTableAssociation: Type: 'AWS::EC2::SubnetRouteTableAssociation' Properties: RouteTableId: !Ref PublicRouteTable SubnetId: !Ref SampleSubnet SampleAWSBatchServiceRole: Type: 'AWS::IAM::Role' Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: batch.amazonaws.com Action: 'sts:AssumeRole' ManagedPolicyArns: - 'arn:aws:iam::aws:policy/service-role/AWSBatchServiceRole' SampleIamInstanceProfile: Type: 'AWS::IAM::InstanceProfile' Properties: Roles: - !Ref SampleEcsInstanceRole SampleEcsInstanceRole: Type: 'AWS::IAM::Role' Properties: AssumeRolePolicyDocument: Version: 2008-10-17 Statement: - Sid: '' Effect: Allow Principal: Service: ec2.amazonaws.com Action: 'sts:AssumeRole' ManagedPolicyArns: - >- arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role SampleJobDefinition: Type: 'AWS::Batch::JobDefinition' Properties: Type: container ContainerProperties: Image: !Join - '' - - 137112412989.dkr.ecr. - !Ref 'AWS::Region' - '.amazonaws.com/amazonlinux:latest' Vcpus: 2 Memory: 2000 Command: - echo - '''hello world''' RetryStrategy: Attempts: 1 SampleJobQueue: Type: 'AWS::Batch::JobQueue' DependsOn: - SampleComputeEnvironment Properties: Priority: 1 ComputeEnvironmentOrder: - Order: 1 ComputeEnvironment: !Ref SampleComputeEnvironment SampleComputeEnvironment: Type: 'AWS::Batch::ComputeEnvironment' DependsOn: - SampleSubnet - SampleSecurityGroup - SampleIamInstanceProfile - SampleAWSBatchServiceRole Properties: Type: MANAGED ComputeResources: Type: EC2 MinvCpus: 0 DesiredvCpus: 0 MaxvCpus: 64 InstanceTypes: - optimal Subnets: - !Ref SampleSubnet SecurityGroupIds: - !Ref SampleSecurityGroup InstanceRole: !Ref SampleIamInstanceProfile ServiceRole: !Ref SampleAWSBatchServiceRole Outputs: SampleComputeEnvironmentArn: Value: !Ref SampleComputeEnvironment SampleJobQueueArn: Value: !Ref SampleJobQueue SampleJobDefinition: Value: !Ref SampleJobDefinition

High-Low Priority

The following example creates a low priority job queue that is mapped to an Amazon EC2 Spot compute environment, and a high priority job queue that is mapped to an On-demand compute environment as well as the Spot compute environment. There are two job definitions: one to mimic a testing job definition, and another to mimic a high-importance application job (each job echoes its name and then exits). You can modify the job definition to run your own Docker container and/or batch scripts.

JSON

Copy
{ "Resources": { "ExampleVPC": { "Type": "AWS::EC2::VPC", "Properties": { "CidrBlock": "10.0.0.0/16" } }, "ExampleInternetGateway": { "Type": "AWS::EC2::InternetGateway", "DependsOn": "ExampleVPC" }, "PublicRouteTable": { "Type": "AWS::EC2::RouteTable", "DependsOn": [ "ExampleVPC", "ExampleVPCGatewayAttachment" ], "Properties": { "VpcId": { "Ref": "ExampleVPC" } } }, "ExampleVPCGatewayAttachment": { "Type": "AWS::EC2::VPCGatewayAttachment", "DependsOn": [ "ExampleVPC", "ExampleInternetGateway" ], "Properties": { "VpcId": { "Ref": "ExampleVPC" }, "InternetGatewayId": { "Ref": "ExampleInternetGateway" } } }, "ExampleSecurityGroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "GroupDescription": "A security group for region-agnostic CFNBatch Launchpad testing", "VpcId": { "Ref": "ExampleVPC" } } }, "ExampleSubnet": { "Type": "AWS::EC2::Subnet", "DependsOn": "ExampleVPCGatewayAttachment", "Properties": { "CidrBlock": "10.0.0.0/24", "VpcId": { "Ref": "ExampleVPC" }, "MapPublicIpOnLaunch": "True" } }, "PublicRoute": { "Type": "AWS::EC2::Route", "DependsOn": [ "PublicRouteTable", "ExampleVPCGatewayAttachment" ], "Properties": { "RouteTableId": { "Ref": "PublicRouteTable" }, "DestinationCidrBlock": "0.0.0.0/0", "GatewayId": { "Ref": "ExampleInternetGateway" } } }, "ExampleSubnetRouteTableAssociation": { "Type": "AWS::EC2::SubnetRouteTableAssociation", "Properties": { "RouteTableId": { "Ref": "PublicRouteTable" }, "SubnetId": { "Ref": "ExampleSubnet" } } }, "ExampleAWSBatchServiceRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "batch.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AWSBatchServiceRole" ] } }, "ExampleIamInstanceProfile": { "Type": "AWS::IAM::InstanceProfile", "Properties": { "Roles": [ { "Ref": "ExampleEcsInstanceRole" } ] } }, "ExampleEcsInstanceRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2008-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role" ] } }, "ExampleSpotIamFleetRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "spotfleet.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }, "ManagedPolicyArns": ["arn:aws:iam::aws:policy/service-role/AmazonEC2SpotFleetRole"] } }, "ImportantProductionApplicationJob": { "Type": "AWS::Batch::JobDefinition", "Properties": { "Type": "container", "ContainerProperties": { "Image": { "Fn::Join" : [ "", ["137112412989.dkr.ecr.", {"Ref": "AWS::Region"}, ".amazonaws.com/amazonlinux:latest" ]] }, "Vcpus": 2, "Memory": 2000, "Command": [ "echo", "Hello, I am a high priority job" ] }, "RetryStrategy": { "Attempts": 1 } } }, "TestApplicationJob": { "Type": "AWS::Batch::JobDefinition", "Properties": { "Type": "container", "ContainerProperties": { "Image": { "Fn::Join" : [ "", ["137112412989.dkr.ecr.", {"Ref": "AWS::Region"}, ".amazonaws.com/amazonlinux:latest" ]] }, "Vcpus": 2, "Memory": 2000, "Command": [ "echo", "Hello, I am a low priority job" ] }, "RetryStrategy": { "Attempts": 1 } } }, "HighPriorityJobQueue": { "Type": "AWS::Batch::JobQueue", "DependsOn": [ "OnDemandComputeEnvironment", "SpotComputeEnvironment" ], "Properties": { "Priority": 1, "ComputeEnvironmentOrder": [{ "Order": 1, "ComputeEnvironment": { "Ref": "OnDemandComputeEnvironment" } }, { "Order": 2, "ComputeEnvironment": { "Ref": "SpotComputeEnvironment" } } ] } }, "LowPriorityJobQueue": { "Type": "AWS::Batch::JobQueue", "DependsOn": [ "SpotComputeEnvironment" ], "Properties": { "JobQueueName": "LowPriorityBatchCloudformationJobqueue", "Priority": 2, "ComputeEnvironmentOrder": [{ "Order": 1, "ComputeEnvironment": { "Ref": "SpotComputeEnvironment" } }] } }, "OnDemandComputeEnvironment": { "Type": "AWS::Batch::ComputeEnvironment", "DependsOn": [ "ExampleSubnet", "ExampleSecurityGroup", "ExampleIamInstanceProfile", "ExampleAWSBatchServiceRole" ], "Properties": { "Type": "MANAGED", "ComputeResources": { "Type": "EC2", "MinvCpus": 0, "DesiredvCpus": 0, "MaxvCpus": 64, "InstanceTypes": [ "optimal" ], "Subnets": [ { "Ref": "ExampleSubnet" } ], "SecurityGroupIds": [ { "Ref": "ExampleSecurityGroup" } ], "InstanceRole": { "Ref": "ExampleIamInstanceProfile" } }, "ServiceRole": { "Ref": "ExampleAWSBatchServiceRole" } } }, "SpotComputeEnvironment": { "Type": "AWS::Batch::ComputeEnvironment", "DependsOn": [ "ExampleSubnet", "ExampleSecurityGroup", "ExampleIamInstanceProfile", "ExampleSpotIamFleetRole", "ExampleAWSBatchServiceRole" ], "Properties": { "Type": "MANAGED", "ComputeResources": { "Type": "SPOT", "MinvCpus": 0, "DesiredvCpus": 0, "MaxvCpus": 64, "InstanceTypes": [ "optimal" ], "Subnets": [ { "Ref": "ExampleSubnet" } ], "SecurityGroupIds": [ { "Ref": "ExampleSecurityGroup" } ], "InstanceRole": { "Ref": "ExampleIamInstanceProfile" }, "BidPercentage": 40, "SpotIamFleetRole": { "Ref": "ExampleSpotIamFleetRole" } }, "ServiceRole": { "Ref": "ExampleAWSBatchServiceRole" } } } }, "Outputs":{ "ImportantProductionApplicationJobArn": { "Value": { "Ref": "ImportantProductionApplicationJob" } }, "TestApplicationJobArn": { "Value": { "Ref": "TestApplicationJob" } }, "HighPriorityJobQueueArn": { "Value": { "Ref": "HighPriorityJobQueue" } }, "LowPriorityJobQueueArn": { "Value": { "Ref": "LowPriorityJobQueue" } }, "OnDemandComputeEnvironmentArn": { "Value": { "Ref": "OnDemandComputeEnvironment" } }, "SpotComputeEnvironmentArn": { "Value": { "Ref": "SpotComputeEnvironment" } } } }

YAML

Copy
Resources: ExampleVPC: Type: 'AWS::EC2::VPC' Properties: CidrBlock: 10.0.0.0/16 ExampleInternetGateway: Type: 'AWS::EC2::InternetGateway' DependsOn: ExampleVPC PublicRouteTable: Type: 'AWS::EC2::RouteTable' DependsOn: - ExampleVPC - ExampleVPCGatewayAttachment Properties: VpcId: !Ref ExampleVPC ExampleVPCGatewayAttachment: Type: 'AWS::EC2::VPCGatewayAttachment' DependsOn: - ExampleVPC - ExampleInternetGateway Properties: VpcId: !Ref ExampleVPC InternetGatewayId: !Ref ExampleInternetGateway ExampleSecurityGroup: Type: 'AWS::EC2::SecurityGroup' Properties: GroupDescription: A security group for region-agnostic CFNBatch Launchpad testing VpcId: !Ref ExampleVPC ExampleSubnet: Type: 'AWS::EC2::Subnet' DependsOn: ExampleVPCGatewayAttachment Properties: CidrBlock: 10.0.0.0/24 VpcId: !Ref ExampleVPC MapPublicIpOnLaunch: 'True' PublicRoute: Type: 'AWS::EC2::Route' DependsOn: - PublicRouteTable - ExampleVPCGatewayAttachment Properties: RouteTableId: !Ref PublicRouteTable DestinationCidrBlock: 0.0.0.0/0 GatewayId: !Ref ExampleInternetGateway ExampleSubnetRouteTableAssociation: Type: 'AWS::EC2::SubnetRouteTableAssociation' Properties: RouteTableId: !Ref PublicRouteTable SubnetId: !Ref ExampleSubnet ExampleAWSBatchServiceRole: Type: 'AWS::IAM::Role' Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: batch.amazonaws.com Action: 'sts:AssumeRole' ManagedPolicyArns: - 'arn:aws:iam::aws:policy/service-role/AWSBatchServiceRole' ExampleIamInstanceProfile: Type: 'AWS::IAM::InstanceProfile' Properties: Roles: - !Ref ExampleEcsInstanceRole ExampleEcsInstanceRole: Type: 'AWS::IAM::Role' Properties: AssumeRolePolicyDocument: Version: 2008-10-17 Statement: - Sid: '' Effect: Allow Principal: Service: ec2.amazonaws.com Action: 'sts:AssumeRole' ManagedPolicyArns: - >- arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role ExampleSpotIamFleetRole: Type: 'AWS::IAM::Role' Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Sid: '' Effect: Allow Principal: Service: spotfleet.amazonaws.com Action: 'sts:AssumeRole' ManagedPolicyArns: - 'arn:aws:iam::aws:policy/service-role/AmazonEC2SpotFleetRole' ImportantProductionApplicationJob: Type: 'AWS::Batch::JobDefinition' Properties: Type: container ContainerProperties: Image: !Join - '' - - 137112412989.dkr.ecr. - !Ref 'AWS::Region' - '.amazonaws.com/amazonlinux:latest' Vcpus: 2 Memory: 2000 Command: - echo - 'Hello, I am a high priority job' RetryStrategy: Attempts: 1 TestApplicationJob: Type: 'AWS::Batch::JobDefinition' Properties: Type: container ContainerProperties: Image: !Join - '' - - 137112412989.dkr.ecr. - !Ref 'AWS::Region' - '.amazonaws.com/amazonlinux:latest' Vcpus: 2 Memory: 2000 Command: - echo - 'Hello, I am a low priority job' RetryStrategy: Attempts: 1 HighPriorityJobQueue: Type: 'AWS::Batch::JobQueue' DependsOn: - OnDemandComputeEnvironment - SpotComputeEnvironment Properties: Priority: 1 ComputeEnvironmentOrder: - Order: 1 ComputeEnvironment: !Ref OnDemandComputeEnvironment - Order: 2 ComputeEnvironment: !Ref SpotComputeEnvironment LowPriorityJobQueue: Type: 'AWS::Batch::JobQueue' DependsOn: - SpotComputeEnvironment Properties: JobQueueName: LowPriorityBatchCloudformationJobqueue Priority: 2 ComputeEnvironmentOrder: - Order: 1 ComputeEnvironment: !Ref SpotComputeEnvironment OnDemandComputeEnvironment: Type: 'AWS::Batch::ComputeEnvironment' DependsOn: - ExampleSubnet - ExampleSecurityGroup - ExampleIamInstanceProfile - ExampleAWSBatchServiceRole Properties: Type: MANAGED ComputeResources: Type: EC2 MinvCpus: 0 DesiredvCpus: 0 MaxvCpus: 64 InstanceTypes: - optimal Subnets: - !Ref ExampleSubnet SecurityGroupIds: - !Ref ExampleSecurityGroup InstanceRole: !Ref ExampleIamInstanceProfile ServiceRole: !Ref ExampleAWSBatchServiceRole SpotComputeEnvironment: Type: 'AWS::Batch::ComputeEnvironment' DependsOn: - ExampleSubnet - ExampleSecurityGroup - ExampleIamInstanceProfile - ExampleSpotIamFleetRole - ExampleAWSBatchServiceRole Properties: Type: MANAGED ComputeResources: Type: SPOT MinvCpus: 0 DesiredvCpus: 0 MaxvCpus: 64 InstanceTypes: - optimal Subnets: - !Ref ExampleSubnet SecurityGroupIds: - !Ref ExampleSecurityGroup InstanceRole: !Ref ExampleIamInstanceProfile BidPercentage: 40 SpotIamFleetRole: !Ref ExampleSpotIamFleetRole ServiceRole: !Ref ExampleAWSBatchServiceRole Outputs: ImportantProductionApplicationJobArn: Value: !Ref ImportantProductionApplicationJob TestApplicationJobArn: Value: !Ref TestApplicationJob HighPriorityJobQueueArn: Value: !Ref HighPriorityJobQueue LowPriorityJobQueueArn: Value: !Ref LowPriorityJobQueue OnDemandComputeEnvironmentArn: Value: !Ref OnDemandComputeEnvironment SpotComputeEnvironmentArn: Value: !Ref SpotComputeEnvironment