Skip to content

delete_compute_environment async

delete_compute_environment(
    *,
    config_overrides: Optional[AsyncBatchClientConfig] = None,
    compute_environment: Optional[String] = None,
) -> DeleteComputeEnvironmentResponse

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:

  • compute_environment (Optional[String], default: None ) –

    The name or Amazon Resource Name (ARN) of the compute environment to delete.

Raises:

  • ClientException –

    These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.

  • ServerException –

    These errors are usually caused by a server issue.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To delete a compute environment This example deletes the P2OnDemand compute environment.

>>> await client.delete_compute_environment(compute_environment='P2OnDemand')
Source code in docs_src/capo_batch/_services/async_batch.py
async def delete_compute_environment(
    self,
    *,
    config_overrides: Optional[AsyncBatchClientConfig] = None,
    compute_environment: Optional["capo_batch.types.string.String"] = None,
) -> "capo_batch.types.delete_compute_environment_response.DeleteComputeEnvironmentResponse":
    """<p>Deletes an Batch compute environment.</p> <p>Before you can delete a compute environment, you must set its state to <code>DISABLED</code> with the <a>UpdateComputeEnvironment</a> API operation and disassociate it from any job queues with the <a>UpdateJobQueue</a> 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.</p>

    Args:
        compute_environment: <p>The name or Amazon Resource Name (ARN) of the compute environment to delete.</p>

    Raises:
        capo_batch.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.</p>
        capo_batch.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
        capo_batch.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To delete a compute environment
        This example deletes the P2OnDemand compute environment.

        >>> await client.delete_compute_environment(compute_environment='P2OnDemand')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_batch.types.delete_compute_environment_request.DeleteComputeEnvironmentRequest]",
    ) -> AsyncOperationResponse[
        "capo_batch.types.delete_compute_environment_response.DeleteComputeEnvironmentResponse"
    ]:
        import capo_batch._operations.aws_batch_v20160810.delete_compute_environment

        (
            output,
            http_response,
        ) = await capo_batch._operations.aws_batch_v20160810.delete_compute_environment.async_delete_compute_environment(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteComputeEnvironment")
    )
    input_: capo_batch.types.delete_compute_environment_request.DeleteComputeEnvironmentRequest = {}
    if compute_environment is not None:
        input_["compute_environment"] = compute_environment

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output