Last updated: Feb 26, 2024
Reading time·4 min
AWS doesn't offer a single-step functionality to rename an S3 bucket, however, we can manually rename one.
In order to rename an S3 bucket, you have to:
Create Bucket
button.name
, select the same region
as the old bucket
and in the Copy settings from existing bucket
section, select your old
bucket to copy settings from.Create bucket
button.To recursively copy the contents of the old bucket to the new bucket, use the s3 sync command, passing it the source and destination buckets as inputs:
$0.005
per 1,000
requests in the us-east-1
region. For example, if your bucket contains 1,000,000
objects, the Copy operation would cost you 1,000 * $0.005 = $5
.aws s3 sync s3://SOURCE_BUCKET s3://DESTINATION_BUCKET
The output of the command shows that the objects of the old bucket were copied to the same paths in the new bucket.
To verify the contents of the old and new buckets are the same, run the
s3 ls
command on both buckets and verify the total size
of the objects is the same.
$0.005
per 1,000
requests, where each request returns a maximum of 1,000
objects (us-east-1
region). For example, if your bucket contains 1,000,000
objects, you would make 1,000
requests and the List operation would cost you $0.005
.# Old bucket aws s3 ls s3://YOUR_OLD_BUCKET --recursive --human-readable --summarize # New bucket aws s3 ls s3://YOUR_NEW_BUCKET --recursive --human-readable --summarize
Total Size
is the same between the buckets, the buckets contain the same objects.Once you're sure that the objects are successfully copied to the new bucket, the last step is to delete the old bucket.
To delete the old bucket, use the
s3 rb
command, setting the --force
parameter, which deletes all of the bucket's
objects.
aws s3 rb s3://YOUR_OLD_BUCKET --force
You can run the s3 ls
command to verify the old bucket has been deleted
successfully.
aws s3 ls s3://bucket-old-123
In short, the associated cost will be insignificant unless you have millions of S3 objects to copy.
The new and old buckets are in the same region, therefore you don't get charged
for bandwidth when copying the objects with the s3 sync
command.
At the time of writing the Copy
requests are priced at about $0.005
per
1,000
requests in the us-east-1
region. One Copy
request is performed for
each file with the aws sync
command.
For example, to sync a bucket that has 1,000,000 objects to another bucket, the
1,000,000 Copy
requests would cost 1000 * $0.005 = $5
.
Delete requests are free of charge, so deleting the old bucket is not associated with a cost, in fact, it saves on storage.
At the time of writing AWS Free Tier covers 20,000 GET Requests; 2,000 PUT, COPY, POST, or LIST Requests each month.
I've also written an article on how to rename a folder in AWS S3.
You can learn more about the related topics by checking out the following tutorials: