How do I fix an INVALID compute environment in AWS Batch?

Last updated: 2019-11-21

My compute environment in AWS Batch is in the INVALID state. How can I resolve this issue?

Short Description

A compute environment is in an INVALID state when that environment isn't configured correctly. An invalid compute environment can't run jobs or be deleted.

If your compute environment is in the INVALID state, choose one of the following resolutions based on the error message that you receive:

  • If you receive the "CLIENT_ERROR - Not authorized to perform sts:AssumeRole (Service: AWSSecurityTokenService; Status Code: 403; Error Code: AccessDenied; Request ID: dc0e2d28-2e99-11e7-b372-7fcc6fb65fe7)" message, complete the steps in the Fix an invalid service role section.
  • If you receive the "Error message - CLIENT_ERROR - Parameter: SpotFleetRequestConfig.IamFleetRole is invalid. (Service: AmazonEC2; Status Code: 400; Error Code: InvalidSpotFleetRequestConfig; Request ID: Parameter: SpotFleetRequestConfig.IamFleetRole is invalid)" message, complete the steps in the Fix an invalid Spot Fleet role section.
  • If you receive the "CLIENT_ERROR - The specified launch template, with template ID lt-1234ab56789cd, does not exist" message, complete the steps in the DISABLE and delete your compute environment section.
  • For the "CLIENT_ERROR - Access denied" message, create a service role with the correct permissions or choose an existing service role with the correct permissions.
  • If you receive the "Internal Error" message, then complete the steps in the Disable and then enable your compute environment section.
  • If you receive the "INVALID CLIENT_ERROR - null (Service: AWSLogs; Status Code: 503; Error Code: null; Request ID: null)" message, then complete the steps in the Disable and then enable your compute environment section.
  • If you receive the "CLIENT_ERROR - The request uses the same client token as previous, but non-identical request" message, then complete the steps in the Disable and then enable your compute environment section.

Resolution

Fix an invalid service role

  1. Open the AWS Batch console.
  2. In the navigation pane, choose Compute environments.
  3. Select the compute environment that's in the INVALID state.
    Note: If your compute environment is in the DISABLED state, choose Enable to enable your compute environment.
  4. Choose Edit.
  5. For Service role, choose a service role with the permissions needed for AWS Batch to make calls to other AWS services.
    Important: Your service role manages the resources that you use with the service. Before you can use the service, you must have an AWS Identity and Access Management (IAM) policy and role that provides the necessary permissions to AWS Batch. You must create a service role with permissions if you don't have one.
  6. Choose Save.

Fix an invalid Spot Fleet role

If you create a managed compute environment that uses Amazon EC2 Spot Fleet Instances, then you must create a role that grants the Spot Fleet permission to bid on, launch, tag, and terminate instances on your behalf.

If you don't have a Spot Fleet role, complete the following steps to create one for your compute environment:

  1. Open the IAM console.
  2. In the navigation pane, choose Roles.
  3. Choose Create role.
  4. Choose AWS service, and then choose EC2 as the service that will use the role that you're creating.
  5. In the Select your use case section, choose EC2 Spot Fleet Role.
    Important: Be careful not to choose the similarly named EC2 - Spot Fleet.
  6. Choose Next: Permissions.
  7. Choose Next: Tags, and then choose Next: Review.
  8. For Role name, enter AmazonEC2SpotFleetRole.
  9. Choose Create role.
    Note: Use your new Spot Fleet role to create new compute environments. Existing compute environments can't change Spot Fleet roles. To terminate the obsolete environment, disable and then delete that environment.
  10. Open the AWS Batch console.
  11. In the navigation pane, choose Compute environments.
  12. Select the compute environment that's in the INVALID state, and then choose Disable.
  13. Choose Delete.

Disable and delete your compute environment

You must disable and delete your compute environment because the launch template associated with your compute environment doesn't exist. This means that you can't use the compute environment associated with your launch template. You must delete that compute environment, and then create a new compute environment.

  1. Open the AWS Batch console.
  2. In the navigation pane, choose Compute environments.
  3. Select the compute environment that's in the INVALID state, and then choose Disable.
  4. Choose Delete.
  5. Create a new compute environment.

Disable and then enable your compute environment

  1. Open the AWS Batch console.
  2. In the navigation pane, choose Compute environments.
  3. Select the compute environment that's in the INVALID state, and then choose Disable.
  4. Select the same compute environment from step 3, and then choose Enable.

Did this article help you?

Anything we could improve?


Need more help?