compute_environments
Creates, updates, deletes, gets or lists a compute_environments resource.
Overview
| Name | compute_environments |
| Type | Resource |
| Id | aws.batch.compute_environments |
Fields
The following fields are returned by SELECT queries:
- describe_compute_environments
| Name | Datatype | Description |
|---|---|---|
compute_environment_arn | string | The Amazon Resource Name (ARN) of the compute environment. |
compute_environment_name | string | The 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_resources | object | An object that represents an Batch compute resource. For more information, see Compute environments in the Batch User Guide. |
container_orchestration_type | string | The orchestration type of the compute environment. The valid values are ECS (default) or EKS. (ECS, EKS) |
context | string | Reserved. |
ecs_cluster_arn | string | The Amazon Resource Name (ARN) of the underlying Amazon ECS cluster that the compute environment uses. |
ecs_settings | object | The Amazon ECS settings for a compute environment, including the CloudWatch Container Insights mode. Use this structure with CreateComputeEnvironment and UpdateComputeEnvironment. |
eks_configuration | object | Configuration for the Amazon EKS cluster that supports the Batch compute environment. The cluster must exist before the compute environment can be created. |
service_role | string | The 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. |
state | string | The 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) |
status | string | The current status of the compute environment (for example, CREATING or VALID). (CREATING, UPDATING, DELETING, DELETED, VALID, INVALID) |
status_reason | string | A short, human-readable string to provide additional details for the current status of the compute environment. |
tags | object | The tags applied to the compute environment. |
type_ | string | The type of the compute environment: MANAGED or UNMANAGED. For more information, see Compute environments in the Batch User Guide. (MANAGED, UNMANAGED) |
unmanagedv_cpus | integer | The maximum number of VCPUs expected to be used for an unmanaged compute environment. |
update_policy | object | Specifies the infrastructure update policy for the compute environment. For more information about infrastructure updates, see Updating compute environments in the Batch User Guide. |
uuid | string | Unique identifier for the compute environment. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_compute_environments | select | region | 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. | |
create_compute_environment | insert | region, computeEnvironmentName, type | 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. | |
update_compute_environment | update | region, computeEnvironment | Updates an Batch compute environment. | |
delete_compute_environment | delete | region | 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. |
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.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- describe_compute_environments
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
- create_compute_environment
- Manifest
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
;
# Description fields are for documentation purposes
- name: compute_environments
props:
- name: region
value: "{{ region }}"
description: Required parameter for the compute_environments resource.
- name: computeEnvironmentName
value: "{{ computeEnvironmentName }}"
- name: type
value: "{{ type }}"
valid_values: ['MANAGED', 'UNMANAGED']
- name: state
value: "{{ state }}"
valid_values: ['ENABLED', 'DISABLED']
- name: unmanagedvCpus
value: {{ unmanagedvCpus }}
- name: computeResources
description: |
An object that represents an Batch compute resource. For more information, see Compute environments in the Batch User Guide.
value:
type_: "{{ type_ }}"
allocationStrategy: "{{ allocationStrategy }}"
minvCpus: {{ minvCpus }}
maxvCpus: {{ maxvCpus }}
desiredvCpus: {{ desiredvCpus }}
instanceTypes:
- "{{ instanceTypes }}"
imageId: "{{ imageId }}"
subnets:
- "{{ subnets }}"
securityGroupIds:
- "{{ securityGroupIds }}"
ec2KeyPair: "{{ ec2KeyPair }}"
instanceRole: "{{ instanceRole }}"
tags: "{{ tags }}"
placementGroup: "{{ placementGroup }}"
bidPercentage: {{ bidPercentage }}
spotIamFleetRole: "{{ spotIamFleetRole }}"
launchTemplate:
launchTemplateId: "{{ launchTemplateId }}"
launchTemplateName: "{{ launchTemplateName }}"
version: "{{ version }}"
overrides:
- launchTemplateId: "{{ launchTemplateId }}"
launchTemplateName: "{{ launchTemplateName }}"
version: "{{ version }}"
targetInstanceTypes: "{{ targetInstanceTypes }}"
userdataType: "{{ userdataType }}"
userdataType: "{{ userdataType }}"
ec2Configuration:
- imageType: "{{ imageType }}"
imageIdOverride: "{{ imageIdOverride }}"
batchImageStatus: "{{ batchImageStatus }}"
imageKubernetesVersion: "{{ imageKubernetesVersion }}"
scalingPolicy:
minScaleDownDelayMinutes: {{ minScaleDownDelayMinutes }}
- name: serviceRole
value: "{{ serviceRole }}"
- name: tags
value: "{{ tags }}"
- name: eksConfiguration
description: |
Configuration for the Amazon EKS cluster that supports the Batch compute environment. The cluster must exist before the compute environment can be created.
value:
eksClusterArn: "{{ eksClusterArn }}"
kubernetesNamespace: "{{ kubernetesNamespace }}"
- name: context
value: "{{ context }}"
- name: ecsSettings
description: |
The Amazon ECS settings for a compute environment, including the CloudWatch Container Insights mode. Use this structure with CreateComputeEnvironment and UpdateComputeEnvironment.
value:
containerInsights: "{{ containerInsights }}"
UPDATE examples
- update_compute_environment
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
- delete_compute_environment
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
;