DEV Community

1 2

Copy of Objects Across Accounts from S3 to S3 Using AWS CLI

“ I have checked the documents of AWS to copy of objects between an s3 bucket across accounts. AWS CLI makes easy and secure transfer of data from s3 to s3. In terms of cost, the solution is cheaper and secure.”

Amazon S3 is an object storage service that offers industry-leading scalability, data availability, security, and performance.

An IAM user is an entity that you create in your AWS account. The IAM user represents the human user or workload who uses the IAM user to interact with AWS resources. An IAM user consists of a name and credentials. IAM policies define permissions for an action regardless of the method that you use to perform the operation.

AWS CloudShell is a browser-based, pre-authenticated shell that you can launch directly from the AWS Management Console.

In this post, you will experience the copy of objects across accounts from s3 to s3 using aws cli. Here I have created a s3 bucket, s3 bucket policy, iam user and iam policy.

Architecture Overview

Image description
The architecture diagram shows the overall deployment architecture with data flow, two aws accounts, s3 bucket, s3 bucket policy, iam user and iam policy.

Solution overview

The blog post consists of the following phases:

  1. In Destination Account, Create a S3 Bucket and IAM User with Security Credential and Permission Policy
  2. In Source Account, Create a S3 Bucket with Objects and Required Bucket Policy. Copy the Data from Source Account Bucket to Destination Account Bucket Using AWS CLI
  3. Output of Data in Destination Bucket

Phase 1: In Destination Account, Create a S3 Bucket and IAM User with Security Credential and Permission Policy

  1. Open the s3 bucket console, create a s3 bucket. Open the IAM console and create a user with the required s3 bucket permission policy. Also enable the access and secret key on the user for copying bucket data from source account bucket to destination account bucket.

Image description

Image description

Image description

Image description

Phase 2: In Source Account, Create a S3 Bucket with Objects and Required Bucket Policy. Copy the Data from Source Account Bucket to Destination Account Bucket Using AWS CLI

  1. Open the s3 bucket console, create a s3 bucket with objects as file and folder. Add a bucket permission policy for cross account user to copy the data from the current bucket to the destination account bucket. Open the cloudshell service, run the aws configure command and run the sync command for bucket data copy.

Image description

Image description

Image description

Phase 3: Output of Data in Destination Bucket

Image description

Image description

Clean-up

In Source Account : S3 bucket. In the Destination Account : S3 bucket, IAM User and IAM Policy.

Pricing

I review the pricing and estimated cost of this example.

In Source Account:

Cost of Simple Storage Service = $0.00

Cost of DataTransfer = $0.00

In Destination Account:

Cost of Simple Storage Service = $0.00

Total Cost = $0.00

Summary

In this post, I showed “how to copy of objects across accounts from s3 to s3 using aws cli”.

For more details on AWS CLI, Checkout Get started AWS CLI, open the AWS CLI.

Thanks for reading!

Connect with me: Linkedin

Top comments (0)