Skip to content

delete_bucket async

delete_bucket(
    bucket_name: BucketName,
    *,
    config_overrides: Optional[AsyncLightsailClientConfig] = None,
    force_delete: Optional[boolean] = None,
) -> DeleteBucketResult

Deletes a Amazon Lightsail bucket.

When you delete your bucket, the bucket name is released and can be reused for a new bucket in your account or another Amazon Web Services account.

Parameters:

  • bucket_name (BucketName) –

    The name of the bucket to delete.

    Use the GetBuckets action to get a list of bucket names that you can specify.

  • force_delete (Optional[boolean], default: None ) –

    A Boolean value that indicates whether to force delete the bucket.

    You must force delete the bucket if it has one of the following conditions:

    • The bucket is the origin of a distribution.

    • The bucket has instances that were granted access to it using the SetResourceAccessForBucket action.

    • The bucket has objects.

    • The bucket has access keys.

    Force deleting a bucket might impact other resources that rely on the bucket, such as instances, distributions, or software that use the issued access keys.

Raises:

  • AccessDeniedException –

    Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.

  • InvalidInputException –

    Lightsail throws this exception when user input does not conform to the validation rules of an input field.

    Domain and distribution APIs are only available in the N. Virginia (us-east-1) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to us-east-1 to create, view, or edit these resources.

  • NotFoundException –

    Lightsail throws this exception when it cannot find a resource.

  • RegionSetupInProgressException –

    Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.

  • ServiceException –

    A general service exception.

  • UnauthenticatedException –

    Lightsail throws this exception when the user has not been authenticated.

  • UnknownServiceError –

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

Source code in docs_src/capo_lightsail/_services/async_lightsail.py
async def delete_bucket(
    self,
    bucket_name: "capo_lightsail.types.bucket_name.BucketName",
    *,
    config_overrides: Optional[AsyncLightsailClientConfig] = None,
    force_delete: Optional["capo_lightsail.types.boolean.boolean"] = None,
) -> "capo_lightsail.types.delete_bucket_result.DeleteBucketResult":
    """<p>Deletes a Amazon Lightsail bucket.</p> <note> <p>When you delete your bucket, the bucket name is released and can be reused for a new bucket in your account or another Amazon Web Services account.</p> </note>

    Args:
        bucket_name: <p>The name of the bucket to delete.</p> <p>Use the <a href="https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetBuckets.html">GetBuckets</a> action to get a list of bucket names that you can specify.</p>
        force_delete: <p>A Boolean value that indicates whether to force delete the bucket.</p> <p>You must force delete the bucket if it has one of the following conditions:</p> <ul> <li> <p>The bucket is the origin of a distribution.</p> </li> <li> <p>The bucket has instances that were granted access to it using the <a href="https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_SetResourceAccessForBucket.html">SetResourceAccessForBucket</a> action.</p> </li> <li> <p>The bucket has objects.</p> </li> <li> <p>The bucket has access keys.</p> </li> </ul> <important> <p>Force deleting a bucket might impact other resources that rely on the bucket, such as instances, distributions, or software that use the issued access keys.</p> </important>

    Raises:
        capo_lightsail.errors.access_denied_exception.AccessDeniedException: <p>Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.</p>
        capo_lightsail.errors.invalid_input_exception.InvalidInputException: <p>Lightsail throws this exception when user input does not conform to the validation rules of an input field.</p> <note> <p>Domain and distribution APIs are only available in the N. Virginia (<code>us-east-1</code>) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to <code>us-east-1</code> to create, view, or edit these resources.</p> </note>
        capo_lightsail.errors.not_found_exception.NotFoundException: <p>Lightsail throws this exception when it cannot find a resource.</p>
        capo_lightsail.errors.region_setup_in_progress_exception.RegionSetupInProgressException: <p>Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.</p>
        capo_lightsail.errors.service_exception.ServiceException: <p>A general service exception.</p>
        capo_lightsail.errors.unauthenticated_exception.UnauthenticatedException: <p>Lightsail throws this exception when the user has not been authenticated.</p>
        capo_lightsail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lightsail.types.delete_bucket_request.DeleteBucketRequest]",
    ) -> AsyncOperationResponse[
        "capo_lightsail.types.delete_bucket_result.DeleteBucketResult"
    ]:
        import capo_lightsail._operations.lightsail_20161128.delete_bucket

        (
            output,
            http_response,
        ) = await capo_lightsail._operations.lightsail_20161128.delete_bucket.async_delete_bucket(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteBucket")
    )
    input_: capo_lightsail.types.delete_bucket_request.DeleteBucketRequest = {
        "bucket_name": bucket_name
    }
    if force_delete is not None:
        input_["force_delete"] = force_delete

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