Manoj Patidar
Manoj Patidar

Reputation: 1171

Move AWS s3 bucket to another aws account

Does AWS provide a way to copy a bucket from one account to a different account? I am uploading several of files to my own bucket for development purposes, but now I'm going to want to switch the bucket to client account.

what all the possiable soluation to do that?

Upvotes: 2

Views: 4963

Answers (2)

Alex
Alex

Reputation: 273

You can not move the whole bucket to another account. You should delete the bucket first in one account and re-create the bucket with the same name in another account. It takes up to 24 hours for a bucket name to become available again after you delete it.

Or you can create the new bucket in a needed account - move all data there and then delete old bucket.

There are different tools that can help you to make this actions but I assume I shouldn't paste any links here.

Do you need to move the bucket to another region or you need to make these changes within one?

Upvotes: 1

Soviut
Soviut

Reputation: 91515

You can copy the contents of one bucket to another owned by a different account, but you cannot transfer ownership of a bucket to a new account. The way to think about it is you're transferring ownership of the objects in the bucket, not the bucket itself.

Amazon has very detailed articles about this procedure.

In the source account, attach the following policy to the bucket you want to copy.

#Bucket policy in the source AWS account
{
     "Version": "2012-10-17",
     "Statement": [
          {
               "Sid": "DelegateS3Access",
               "Effect": "Allow",
               "Principal": {"AWS": "222222222222"},
               "Action": "s3:*",
               "Resource": [
                    "arn:aws:s3:::sourcebucket/*",
                    "arn:aws:s3:::sourcebucket"
               ]
          }
     ]
}

Attach a policy to a user or group in the destination AWS account to delegate access to the bucket in the source AWS account. If you attach the policy to a group, make sure that the IAM user is a member of the group.

#User or group policy in the destination AWS account
{
     "Version": "2012-10-17",
     "Statement": {
          "Effect": "Allow",
          "Action": "s3:*",
          "Resource": [
               "arn:aws:s3:::sourcebucket",
               "arn:aws:s3:::sourcebucket/*",
               "arn:aws:s3:::destinationbucket",
               "arn:aws:s3:::destinationbucket/*"
          ]
     }
}

When these steps are completed, you can copy objects by using the AWS Command Line Interface (CLI) commands cp or sync. For example, the following aws s3 sync command could be used to copy the contents from a bucket in the source AWS account to a bucket in the destination AWS account.

aws s3 sync s3://sourcebucket s3://destinationbucket

Upvotes: 3

Related Questions