I had to transfer the S3 bucket objects form one AWS account (Source account) to another AWS account (Destination Account) within the same region. But, transferring the objects form one AWS account to another is not straight forward.
According to AWS documentation its transfer the ownership of S3 objects from one account to another AWS account rather than transferring the objects itself.
To transfer this ownership we have to go through multiple steps. Here, I will explain how to perform this action in few simple steps.
We should have following
- Two different AWS accounts (Source account and Destination account).
- S3 buckets in both account (Source S3 bucket and Destination S3 bucket).
- Source S3 bucket should have some objects (images, files, videos, etc).
- Get the destination AWS account number (check AWS official document to find the AWS account).
Just for demo I am assuming following name and region
- Source bucket name :
- Destination bucket name :
- Destination AWS account number :
- Source region name :
ap-southeast-2(find the list of the AWS regions )
- Destination region name :
ap-southeast-2(find the list of the AWS regions ).
But, you can choose your own bucket name and region name.
Create and Set-up the Source S3 bucket in Source AWS account
Create the S3 bucket in source account named
prakash_source_s3_bucket( check the AWS official document to create the S3 bucket).
Attach the following policy to the newly created S3 bucket( check the AWS official document to attach the policy to S3 bucket).
Image 1 : Attach the policy to source S3 bucket
Create the Destination S3 bucket in Destination AWS account
Create the S3 bucket in destination account named
( check the AWS official document to create the S3 bucket).
And upload some objects (images, files, videos, etc.)
Note : we don’t need to set-up any configuration like source S3 bucket.
Create and set-up an IAM user in Destination AWS account
Create an IAM user in the destination account (check the official AWS document on how to create an IAM user) and attach the policy to the newly created IAM user so that we can transfer the objects the destination S3 bucket(check the official AWS document on how to attach the policy to IAM user).
Image 2 : Attach policy to the IAM user
Create Access key for newly created IAM user
In AWS destination account we need to create the access key ID and Secret access key for newly created IAM user. (to create the access follow the AWS official document ).
Image 3 : Create access key for IAM User
Install AWS CLI on local machine
Now, we have to install the AWS CLI in our local machine so that we can run AWS command to transfer the objects form source S3 bucket to destination S3 bucket. (Follow the official document on how to install the AWS CLI on local machine). AWS CLI is available for Windows, Linux, macOS, or Unix.
Configure AWS CLI for IAM user
Configure the AWS CLI for newly created IAM user on destination account(follow the official document).
Image 4 : AWS configuration
Copy S3 objects to another account.
Finally, it’s time to run the AWS CLI command to copy the S3 objects from source account to the destination account. We have to run the below sync command to start the process.
Once we run the AWS command we can see the file sync process in console. The sync time is depend on the size of the source file.
Note : do not close the object sync progress console window.
Now, we learned how to copy S3 bucket objects from one account to the another AWS account(transfer the ownership of S3 objects from one account to another AWS account).