‹ Return to How tos

Deleting buckets in Amazon Lightsail

Last updated: July 14, 2021

Delete your bucket in the Amazon Lightsail object storage service if you're no longer using it. When you delete your bucket, all objects in the bucket, including stored versions of objects and access keys, are permanently deleted.

For more information about buckets, see Object storage in Amazon Lightsail.

Force deleting a bucket

Buckets that have one of the following conditions cannot be deleted unless you acknowledge the deletion:

  • The bucket is the origin of a distribution.

  • The bucket has instances attached to it.

  • The bucket has objects.

  • The bucket has access keys.

You must acknowledge the deletion to ensure that you don't disrupt an existing workflow that relies on the bucket. For example, a WordPress website that is storing media on the bucket or a distribution that is caching and serving objects in your bucket.

To acknowledge deletion of a bucket that has one of the preceding conditions, you must force delete the bucket. Before you delete the bucket, the Lightsail service prompts you about which of these conditions exist on it. If you use the Lightsail console to delete your bucket, you are presented with the option to force delete it. If you use the AWS CLI, you must specify the --force-delete flag when making a delete-bucket request. Both of these procedures are covered in the Delete your bucket using the Lightsail console and Delete your bucket using the sections of this guide.

Delete your bucket using the Lightsail console

Complete the following procedure to delete your bucket using the Lightsail console.

  1. Sign in to the Lightsail console.

  2. On the Lightsail home page, choose the Storage tab.

  3. Choose the name of the bucket that you want to delete.

  4. Choose the ellipsis (⋮) icon in the tab menu, then choose Delete.

  5. Choose Delete bucket.

  6. In the prompt that appears, confirm if your bucket meets any of the following conditions:

    • Contains an object

    • Has access keys

    • Is attached to an instance

    • Is the origin of a distribution

    If it has any of those conditions, then you must choose to force delete the bucket.

  7. Choose one of the following options:

    • Choose Force delete to delete your bucket even if it has any of the conditions listed in step 6 of this procedure.

    • Choose Yes, delete to delete your bucket when it doesn't have any of the conditions listed in step 6 of this procedure.

    • Choose No, cancel to cancel deletion.

Delete your bucket using the

Complete the following procedure to delete your bucket using the AWS Command Line Interface (AWS CLI). You do this by using the delete-bucket command. For more information, see delete-bucket in the AWS CLI Command Reference.

Note

You must install the AWS CLI and configure it for Lightsail and Amazon S3 before continuing with this procedure. For more information, see Configuring the AWS Command Line Interface to work with Amazon Lightsail.

  1. Open a Command Prompt or Terminal window.

  2. In the command prompt or terminal window, enter one of the following commands:

    • Enter the following command to delete a bucket that doesn't have the conditions listed in the Force deleting a bucket section of this guide.

      aws lightsail delete-bucket --bucket-name BucketName
    • Enter the following command to force delete a bucket that has the conditions listed in the Force deleting a bucket section of this guide.

      aws lightsail delete-bucket --bucket-name BucketName --force-delete

    In the commands, replace BucketName with the name of the bucket you want to delete.

    Example:

    aws lightsail delete-bucket --bucket-name DOC-EXAMPLE-BUCKET

    You should see a result similar to the following example:

    Result of the delete bucket request

Managing buckets and objects in Lightsail

These are the general steps to manage your Lightsail object storage bucket:

  1. Learn about objects and buckets in the Amazon Lightsail object storage service. For more information, see Object storage in Amazon Lightsail.

  2. Learn about the names that you can give your buckets in Amazon Lightsail. For more information, see Bucket naming rules in Amazon Lightsail.

  3. Get started with the Lightsail object storage service by creating a bucket. For more information, see Creating buckets in Amazon Lightsail.

  4. Learn about security best practices for buckets and the access permissions that you can configure for your bucket. You can make all objects in your bucket public or private, or you can choose to make individual objects public. You can also grant access to your bucket by creating access keys, attaching instances to your bucket, and granting access to other AWS accounts. For more information, see Security Best Practices for Amazon Lightsail object storage and Understanding bucket permissions in Amazon Lightsail.

    After learning about bucket access permissions, see the following guides to grant access to your bucket:

  5. Create an IAM policy that grants a user the ability to manage a bucket in Lightsail. For more information, see IAM policy to manage buckets in Amazon Lightsail.

  6. Learn about the way that objects in your bucket are labeled and identified. For more information, see Understanding object key names in Amazon Lightsail.

  7. Learn how to upload files and manage objects in your buckets. For more information, see the following guides.

  8. Enable object versioning to preserve, retrieve, and restore every version of every object stored in your bucket. For more information, see Enabling and suspending object versioning in a bucket in Amazon Lightsail.

  9. After enabling object versioning, you can restore previous versions of objects in your bucket. For more information, see Restoring previous versions of objects in a bucket in Amazon Lightsail.

  10. Monitor the utilization of your bucket. For more information, see Viewing metrics for your bucket in Amazon Lightsail.

  11. Configure an alarm for bucket metrics to be notified when the utilization of your bucket crosses a threshold. For more information, see Creating bucket metric alarms in Amazon Lightsail.

  12. Change the storage plan of your bucket if it's running low on storage and network transfer. For more information, see Changing the plan of your bucket in Amazon Lightsail.

  13. Learn how to connect your bucket to other resources. For more information, see the following tutorials.

  14. Delete your bucket if you're no longer using it. For more information, see Deleting buckets in Amazon Lightsail.