
How to transfer files between AWS S3 and AWS EC2?
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.


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
Facts:
Did you know.
- 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.
- You can’t detach the root volume of an instance without stopping the instance.
- 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.