Use DeleteComputeEnvironment with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DeleteComputeEnvironment with an AWS SDK or CLI

The following code examples show how to use DeleteComputeEnvironment.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

CLI
AWS CLI

To delete a compute environment

This example deletes the P2OnDemand compute environment.

Command:

aws batch delete-compute-environment --compute-environment P2OnDemand
Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

public CompletableFuture<DeleteComputeEnvironmentResponse> deleteComputeEnvironmentAsync(String computeEnvironmentName) { DeleteComputeEnvironmentRequest deleteComputeEnvironment = DeleteComputeEnvironmentRequest.builder() .computeEnvironment(computeEnvironmentName) .build(); return getAsyncClient().deleteComputeEnvironment(deleteComputeEnvironment) .whenComplete((response, ex) -> { if (ex != null) { Throwable cause = ex.getCause(); if (cause instanceof BatchException) { throw new RuntimeException(cause); } else { throw new RuntimeException("Unexpected error: " + cause.getMessage(), cause); } } }); }