How can I migrate my Amazon S3 bucket to another AWS Region?

Last updated: 2019-05-17

I want to move my Amazon Simple Storage Service (Amazon S3) bucket to another AWS Region. How can I do that?

Short Description

You can't migrate an existing S3 bucket into another AWS Region. Instead, create a new bucket in the destination Region. Then, copy the data from the source bucket into the new bucket.

To use the same bucket name in the destination Region, you must be able to delete the source bucket before creating the new bucket. This is because bucket names must be unique among all existing buckets in Amazon S3. You can use a temporary bucket to store data while you delete the source bucket. 

Resolution

Follow these steps to recreate your source bucket in another Region using the same bucket name:

Warning: When the bucket name is available, it's available to all AWS customers. You can't reserve a bucket name. If the name becomes available and another user claims it, you can't take back the name.

1.    Create a temporary bucket in the destination Region (Destination Bucket A).

2.    Copy the data from the source bucket into Destination Bucket A. One way to perform this copy is to run the sync command using the AWS Command Line Interface (AWS CLI). Note the following:

  • If you want the new bucket and its objects to belong to another AWS account, the copy must be performed by an AWS Identity and Access Management (IAM) user or role with cross-account permissions. If the IAM identity belongs to the source account, then the identity must have permissions to the destination bucket. If the IAM identity belongs to the destination account, the identity must have permissions to the source bucket.
  • If you perform the copy using an IAM identity from the source account, be sure to set the access control lists (ACLs) of the objects to "bucket-owner-full-control". This is a canned ACL that grants the bucket owner full access to the objects.
  • The duration of the copy varies depending on the amount of data that you're copying. To reduce the time it takes to complete the operation, you can launch multiple instances of data-transfer sessions. For example, you can run parallel uploads using the AWS CLI.
 
3.    After the copy operation is complete, delete the source bucket.

4.    Run the bucket-exists command to verify that the bucket name is available. If the command returns "Waiter BucketExists failed: Max attempts exceeded," then you can use the bucket name.

Note: After you delete the bucket, it might take some time before you can reuse the name to create a new bucket in the destination Region. To claim the bucket name as soon as it's available, you can run a script to continuously check the bucket name's availability. Then, the script can issue the CreateBucket API call when the name is available.

5.    Create a new bucket in the destination Region (Destination Bucket B) with the name of the source bucket.

6.    Copy the data from Destination Bucket A into Destination Bucket B.

7.    After the copy operation is complete, delete Destination Bucket A.