How to transfer files between AWS S3 and AWS EC2?

How to transfer files between AWS S3 and AWS EC2?

Share Now
2 min read
Steps to Transfer files:

The Procedure to transfer files between AWS S3 and AWS EC2, first, you have to log in and Create an IAM Role to access S3 from EC2.

Create a user in IAM and make a note of those access key & Secret Access key [ Make sure to use Programmatic access ].

When you assign a policy using the Permission section, make sure to give Full S3 access to cloud storage database.

transfer files between AWS S3 and AWS EC2

Login to your EC2 and use the putty for Windows or Linux terminal for the command line.

Use the command

  • aws configure

This will prompt you to enter the access key and secret access key.

You have to enter that information from your above user creation Access & Secret access key.

Once you are done setting up your command line, you are all set to access the S3 bucket from your EC2 instance through command line.

Create Amazon Bucket
  • Aws s3 mb bucket_name
Delete Bucket
  • Aws s3 rb bucket_name
List buckets
  • Aws s3 ls or
  • aws s3 ls http://s3://bucket_name
Sync/backup data from source to S3. -→ Interview points
  • Aws s3 sync /var/log/ http://s3://my_bucket (Synching/backing up log files to S3)

To make that in a regular interval, add the command to cron to backup every week.

Delete the files not present in Source.

  • Aws s3 sync /var/log/ http://s3://bukcte_name –delete

Delete objects from bucket.

  • Aws s3 rm http://s3://my_bucket/file.txt


Did you know.

  1. Stopped AWS instances also costs money if it has Elastic IP associated, the elastic IP is chargeable if it is kept unused. The EBS volume attached to the instance will also cost on its regular price per hour.
  2. You can’t detach the root volume of an instance without stopping the instance.
  3. Date volumes of an instance can be detached while the instance is still running.

At Lia Infraservices, Our AWS Cloud Migration Services ensures a phase-driven step-by-step strategy to migrate your existing IT systems to the AWS Cloud.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave comment

Your email address will not be published. Required fields are marked with *.