How do I update an AWS Batch EC2 compute environment?

3 minute read
0

I want to update an Amazon Elastic Compute Cloud (Amazon EC2) compute environment for AWS Batch. However, I don’t see options to change properties on the AWS Batch console.

Short description

To update the infrastructure settings of an AWS Batch EC2 compute environment, use an allocation strategy other than BEST_FIT. The compute environment must also use a service-linked role.

If you don't meet the allocation strategy requirements, then the infrastructure configuration doesn't update. As a result, you might see the following error message:

"An error occurred (ClientException) when calling the UpdateComputeEnvironment operation: Fields allocationStrategy, bidPercentage, ec2Configuration, ec2KeyPair, imageId, instanceRole, instanceTypes, launchTemplate, placementGroup, securityGroupIds, subnets, tags, type, updatePolicy, updateToLatestImageVersion, context can be updated for CE only with Allocation Strategy BEST_FIT_PROGRESSIVE and SPOT_CAPACITY_OPTIMIZED."

If the allocation strategy is BEST_FIT or you don't use a service-linked role, then recreate the compute environment.

For more information, see Updating compute environments.

Resolution

If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.

To update the AWS Batch EC2 compute environment, use either the AWS Batch console or the AWS CLI.

AWS Batch console

Complete the following steps:

  1. Open the AWS Batch console.
  2. In the navigation pane, choose Compute environments.
  3. Select the compute environment that you want to update, and then choose Edit.
  4. Choose Update AMI to latest version, and then turn on Update.
  5. Choose Save changes.

Note: If you use the default Amazon Elastic Container Service (Amazon ECS) optimized Amazon Machine Image (AMI) for your compute environment, then the AMI doesn't automatically update. To update the AMI, set the updateToLatestImageVersion parameter to true.

AWS CLI

Run the update-compute-environment command. If you update to the latest ECS optimized AMI, then specify the updateToLatestImageVersion parameter:

aws batch update-compute-environment --compute-environment COMPUTE_ENVIRONMENT --compute-resources updateToLatestImageVersion=true

Note: Replace COMPUTE_ENVIRONMENT with your compute environment name.

Recreate the compute environment

If you don't meet the requirements for the AWS Batch EC2 compute environment, then recreate the environment.

Complete the following steps:

  1. Create a new compute environment with the new AMI.
  2. Add the compute environment to an existing job queue.
  3. Remove the old compute environment from your job queue.
  4. Delete the old compute environment.

For more information, see Managed compute environments.

AWS OFFICIAL
AWS OFFICIALUpdated 2 months ago