File Transfer AWS EC2 to S3 Bucket (Upload and Download)

In this article, we are going to learn how to transfer files AWS EC2 to S3 drive.

Transfer AWS to EC2 (Upload)

  1. Create an IAM role with S3 write access or admin access
  2. Map the IAM role to an EC2 instance
  3. Run the AWS s3 cp command to copy the files to the S3 bucket

1. Create an IAM role with S3 write access or admin access

Login to your AWS Management Console and go to IAM. Create a new IAM role with S3 Admin Access which can be lateral mapped to the EC2 instance for easy S3 and EC2 integration.

2. Map the IAM role to an EC2 instance

Choose the EC2 instance you want to assign this IAM role to. Click on Actions > Security> Modify IAM Role Search for the IAM Role we have created in the previous step and select it and hit Save. EC2 to S3

4. Run the AWS s3 cp command to copy the files to the S3 bucket

aws s3 cp my_copied_file.ext s3://my_bucket/my_folder/my_file.ext

Steps to copy files from S3 bucket to EC2 instance (Download)

To copy the files from S3 bucket to EC2 instance, you have to follow the same steps except changing the source and destination on the Three Step

  1. Create an IAM role with S3 write access or admin access
  2. Map the IAM role to an EC2 instance
  3. Run the AWS s3 cp command to copy the files from S3 to EC2

 

aws s3 cp s3://my_bucket/my_folder/my_file.ext my_copied_file.ext

Leave a Reply

Your email address will not be published.