AWS CloudFormation
User Guide (Version )

AWS::Batch::ComputeEnvironment

The AWS::Batch::ComputeEnvironment resource defines 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

{ "Type" : "AWS::Batch::ComputeEnvironment", "Properties" : { "ComputeEnvironmentName" : String, "ComputeResources" : ComputeResources, "ServiceRole" : String, "State" : String, "Type" : String } }

YAML

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

Properties

ComputeEnvironmentName

The name for your compute environment. Up to 128 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.

Required: No

Type: String

Update requires: Replacement

ComputeResources

The ComputeResources property type specifies details of the compute resources managed by the compute environment. This parameter is required for managed compute environments. For more information, see Compute Environments in the AWS Batch User Guide.

Required: No

Type: ComputeResources

Update requires: No interruption

ServiceRole

The full Amazon Resource Name (ARN) of the IAM role that allows AWS Batch to make calls to other AWS services on your behalf.

If your specified role has a path other than /, then you must either specify the full role ARN (this is recommended) or prefix the role name with the path.

Note

Depending on how you created your AWS Batch service role, its ARN may contain the service-role path prefix. When you only specify the name of the service role, AWS Batch assumes that your ARN does not use the service-role path prefix. Because of this, we recommend that you specify the full ARN of your service role when you create compute environments.

Required: Yes

Type: String

Update requires: No interruption

State

The state of the compute environment. If the state is ENABLED, then the compute environment accepts jobs from a queue and can scale out automatically based on queues.

Required: No

Type: String

Allowed Values: DISABLED | ENABLED

Update requires: No interruption

Type

The type of the compute environment. For more information, see Compute Environments in the AWS Batch User Guide.

Required: Yes

Type: String

Allowed Values: MANAGED | UNMANAGED

Update requires: Replacement

Return Values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref 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

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

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

See Also