Skip to main content

compute_environments

Creates, updates, deletes, gets or lists a compute_environments resource.

Overview

Namecompute_environments
TypeResource
Idaws.batch.compute_environments

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
compute_environment_arnstringThe Amazon Resource Name (ARN) of the compute environment.
compute_environment_namestringThe name of the compute environment. It can be up to 128 characters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).
compute_resourcesobjectAn object that represents an Batch compute resource. For more information, see Compute environments in the Batch User Guide.
container_orchestration_typestringThe orchestration type of the compute environment. The valid values are ECS (default) or EKS. (ECS, EKS)
contextstringReserved.
ecs_cluster_arnstringThe Amazon Resource Name (ARN) of the underlying Amazon ECS cluster that the compute environment uses.
ecs_settingsobjectThe Amazon ECS settings for a compute environment, including the CloudWatch Container Insights mode. Use this structure with CreateComputeEnvironment and UpdateComputeEnvironment.
eks_configurationobjectConfiguration for the Amazon EKS cluster that supports the Batch compute environment. The cluster must exist before the compute environment can be created.
service_rolestringThe service role that's associated with the compute environment that allows Batch to make calls to Amazon Web Services API operations on your behalf. For more information, see Batch service IAM role in the Batch User Guide.
statestringThe state of the compute environment. The valid values are ENABLED or DISABLED. If the state is ENABLED, then the Batch scheduler can attempt to place jobs from an associated job queue on the compute resources within the environment. If the compute environment is managed, then it can scale its instances out or in automatically based on the job queue demand. If the state is DISABLED, then the Batch scheduler doesn't attempt to place jobs within the environment. Jobs in a STARTING or RUNNING state continue to progress normally. Managed compute environments in the DISABLED state don't scale out. Compute environments in a DISABLED state may continue to incur billing charges, for example, if they have running instances due to jobs that are still executing or a non-zero minvCpus setting. To prevent additional charges, disable and delete the compute environment. When an instance is idle, the instance scales down to the minvCpus value. However, the instance size doesn't change. For example, consider a c5.8xlarge instance with a minvCpus value of 4 and a desiredvCpus value of 36. This instance doesn't scale down to a c5.large instance. (ENABLED, DISABLED)
statusstringThe current status of the compute environment (for example, CREATING or VALID). (CREATING, UPDATING, DELETING, DELETED, VALID, INVALID)
status_reasonstringA short, human-readable string to provide additional details for the current status of the compute environment.
tagsobjectThe tags applied to the compute environment.
type_stringThe type of the compute environment: MANAGED or UNMANAGED. For more information, see Compute environments in the Batch User Guide. (MANAGED, UNMANAGED)
unmanagedv_cpusintegerThe maximum number of VCPUs expected to be used for an unmanaged compute environment.
update_policyobjectSpecifies the infrastructure update policy for the compute environment. For more information about infrastructure updates, see Updating compute environments in the Batch User Guide.
uuidstringUnique identifier for the compute environment.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_compute_environmentsselectregionDescribes one or more of your compute environments. If you're using an unmanaged compute environment, you can use the DescribeComputeEnvironment operation to determine the ecsClusterArn that you launch your Amazon ECS container instances into.
create_compute_environmentinsertregion, computeEnvironmentName, typeCreates an Batch compute environment. You can create MANAGED or UNMANAGED compute environments. MANAGED compute environments can use Amazon EC2 or Fargate resources. UNMANAGED compute environments can only use EC2 resources. In a managed compute environment, Batch manages the capacity and instance types of the compute resources within the environment. This is based on the compute resource specification that you define or the launch template that you specify when you create the compute environment. Either, you can choose to use EC2 On-Demand Instances and EC2 Spot Instances. Or, you can use Fargate and Fargate Spot capacity in your managed compute environment. You can optionally set a maximum price so that Spot Instances only launch when the Spot Instance price is less than a specified percentage of the On-Demand price. In an unmanaged compute environment, you can manage your own EC2 compute resources and have flexibility with how you configure your compute resources. For example, you can use custom AMIs. However, you must verify that each of your AMIs meet the Amazon ECS container instance AMI specification. For more information, see container instance AMIs in the Amazon Elastic Container Service Developer Guide. After you created your unmanaged compute environment, you can use the DescribeComputeEnvironments operation to find the Amazon ECS cluster that's associated with it. Then, launch your container instances into that Amazon ECS cluster. For more information, see Launching an Amazon ECS container instance in the Amazon Elastic Container Service Developer Guide. Batch doesn't automatically upgrade the AMIs in a compute environment after it's created. For more information on how to update a compute environment's AMI, see Updating compute environments in the Batch User Guide.
update_compute_environmentupdateregion, computeEnvironmentUpdates an Batch compute environment.
delete_compute_environmentdeleteregionDeletes an Batch compute environment. Before you can delete a compute environment, you must set its state to DISABLED with the UpdateComputeEnvironment API operation and disassociate it from any job queues with the UpdateJobQueue API operation. Compute environments that use Fargate resources must terminate all active jobs on that compute environment before deleting the compute environment. If this isn't done, the compute environment enters an invalid state.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

Describes one or more of your compute environments. If you're using an unmanaged compute environment, you can use the DescribeComputeEnvironment operation to determine the ecsClusterArn that you launch your Amazon ECS container instances into.

SELECT
compute_environment_arn,
compute_environment_name,
compute_resources,
container_orchestration_type,
context,
ecs_cluster_arn,
ecs_settings,
eks_configuration,
service_role,
state,
status,
status_reason,
tags,
type_,
unmanagedv_cpus,
update_policy,
uuid
FROM aws.batch.compute_environments
WHERE region = '{{ region }}' -- required
;

INSERT examples

Creates an Batch compute environment. You can create MANAGED or UNMANAGED compute environments. MANAGED compute environments can use Amazon EC2 or Fargate resources. UNMANAGED compute environments can only use EC2 resources. In a managed compute environment, Batch manages the capacity and instance types of the compute resources within the environment. This is based on the compute resource specification that you define or the launch template that you specify when you create the compute environment. Either, you can choose to use EC2 On-Demand Instances and EC2 Spot Instances. Or, you can use Fargate and Fargate Spot capacity in your managed compute environment. You can optionally set a maximum price so that Spot Instances only launch when the Spot Instance price is less than a specified percentage of the On-Demand price. In an unmanaged compute environment, you can manage your own EC2 compute resources and have flexibility with how you configure your compute resources. For example, you can use custom AMIs. However, you must verify that each of your AMIs meet the Amazon ECS container instance AMI specification. For more information, see container instance AMIs in the Amazon Elastic Container Service Developer Guide. After you created your unmanaged compute environment, you can use the DescribeComputeEnvironments operation to find the Amazon ECS cluster that's associated with it. Then, launch your container instances into that Amazon ECS cluster. For more information, see Launching an Amazon ECS container instance in the Amazon Elastic Container Service Developer Guide. Batch doesn't automatically upgrade the AMIs in a compute environment after it's created. For more information on how to update a compute environment's AMI, see Updating compute environments in the Batch User Guide.

INSERT INTO aws.batch.compute_environments (
computeEnvironmentName,
type,
state,
unmanagedvCpus,
computeResources,
serviceRole,
tags,
eksConfiguration,
context,
ecsSettings,
region
)
SELECT
'{{ computeEnvironmentName }}' /* required */,
'{{ type }}' /* required */,
'{{ state }}',
{{ unmanagedvCpus }},
'{{ computeResources }}',
'{{ serviceRole }}',
'{{ tags }}',
'{{ eksConfiguration }}',
'{{ context }}',
'{{ ecsSettings }}',
'{{ region }}'
RETURNING
compute_environment_arn,
compute_environment_name
;

UPDATE examples

Updates an Batch compute environment.

UPDATE aws.batch.compute_environments
SET
computeEnvironment = '{{ computeEnvironment }}',
state = '{{ state }}',
unmanagedvCpus = {{ unmanagedvCpus }},
computeResources = '{{ computeResources }}',
serviceRole = '{{ serviceRole }}',
updatePolicy = '{{ updatePolicy }}',
context = '{{ context }}',
ecsSettings = '{{ ecsSettings }}'
WHERE
region = '{{ region }}' --required
AND computeEnvironment = '{{ computeEnvironment }}' --required
RETURNING
compute_environment_arn,
compute_environment_name;

DELETE examples

Deletes an Batch compute environment. Before you can delete a compute environment, you must set its state to DISABLED with the UpdateComputeEnvironment API operation and disassociate it from any job queues with the UpdateJobQueue API operation. Compute environments that use Fargate resources must terminate all active jobs on that compute environment before deleting the compute environment. If this isn't done, the compute environment enters an invalid state.

DELETE FROM aws.batch.compute_environments
WHERE region = '{{ region }}' --required
;