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

AWS::Batch::ComputeEnvironment

The AWS::Batch::ComputeEnvironment resource to define your AWS Batch compute environment. For more information, see Compute Environments 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::ComputeEnvironment", "Properties" : { "Type" : String, "ServiceRole" : String, "ComputeEnvironmentName" : String, "ComputeResources" : ComputeResources, "State" : String } }

YAML

Copy
Type: "AWS::Batch::ComputeEnvironment" Properties: Type: String ServiceRole: String ComputeEnvironmentName: String ComputeResources: ComputeResources State: String

Properties

Type

The type of the compute environment.

Required: yes

Type: String

Update requires: Replacement

ServiceRole

The service role associated with the compute environment that allows AWS Batch to make calls to AWS API operations on your behalf.

Required: yes

Type: String

Update requires: No Interruption

ComputeEnvironmentName

The name of the compute environment.

Required: no

Type: String

Update requires: Replacement

ComputeResources

The compute resources defined for the compute environment.

Required: yes

Type: AWS Batch ComputeEnvironment ComputeResources

Update requires: No Interruption

State

The state of the compute environment. The valid values are ENABLED or DISABLED. An ENABLED state indicates that you can register instances with the compute environment and that the associated instances can accept jobs.

Required: no

Type: String

Update requires: No Interruption

Return Values

Ref

When you pass the logical ID of an AWS::Batch::ComputeEnvironment resource to the intrinsic Ref function, the function returns the compute environment ARN, such as arn:aws:batch:us-east-1:555555555555:compute-environment/M4OnDemand.

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

Examples

Managed Compute Environment

The following example creates a managed compute environment called C4OnDemand that uses C4 On-Demand instances and a custom AMI.

JSON

Copy
{ "ComputeEnvironment": { "Type": "AWS::Batch::ComputeEnvironment", "Properties": { "Type": "MANAGED", "ServiceRole": "arn:aws:iam::111122223333:role/service-role/AWSBatchServiceRole", "ComputeEnvironmentName": "C4OnDemand", "ComputeResources": { "MaxvCpus": 128, "SecurityGroupIds": [ "sg-abcd1234" ], "Type": "EC2", "Subnets": [ "subnet-aaaaaaaa", "subnet-bbbbbbbb", "subnet-cccccccc" ], "MinvCpus": 0, "ImageId": "ami-a1b2c3d4", "InstanceRole": "ecsInstanceRole", "InstanceTypes": [ "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge" ], "Ec2KeyPair": "id_rsa", "Tags": {"Name": "Batch Instance - C4OnDemand"}, "DesiredvCpus": 48 }, "State": "ENABLED" } } }

YAML

Copy
ComputeEnvironment: Type: AWS::Batch::ComputeEnvironment Properties: Type: MANAGED ServiceRole: arn:aws:iam::111122223333:role/service-role/AWSBatchServiceRole ComputeEnvironmentName: C4OnDemand ComputeResources: MaxvCpus: 128 SecurityGroupIds: - sg-abcd1234 Type: EC2 Subnets: - subnet-aaaaaaaa - subnet-bbbbbbbb - subnet-cccccccc MinvCpus: 0 ImageId: ami-a1b2c3d4 InstanceRole: ecsInstanceRole InstanceTypes: - c4.large - c4.xlarge - c4.2xlarge - c4.4xlarge - c4.8xlarge Ec2KeyPair: id_rsa Tags: {"Name": "Batch Instance - C4OnDemand"} DesiredvCpus: 48 State: ENABLED

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