Transfer files from EC2 to S3

This tutorial talked about how to transfer files from EC2 to S3.

Create IAM

  1. Login to your IAM dashboard, create a group with s3 full access permission.
  2. Create a user and assign to the group

Aws configure

Login to your ec2 instance, you need to configure aws with following command.

[ec2-user@ip-xxx-xxx-xxx-xxx html]$ aws configure
AWS Access Key ID [None]: XXXXXXXXXXXXXXXXXXX
AWS Secret Access Key [None]: XXXXXXXXXXXXXXXXX
Default region name [None]:  enter
Default output format [None]:  enter

 

Test your connection

Test the following command to your S3 bucket and folder.

[ec2-user@ip-xxx-xxx-xxx-xxx html]$ aws s3 ls s3://migratefolder/temp/
2016-04-04 05:53:49          0 
[ec2-user@ip-XXX-XXX-XXX-XXX html]$ 

 

Transfer file

Now you can transfer file from your ec2 to s3.

[ec2-user@ip-xxx-xxx-xxx-xxx html]$ aws s3 cp abc.tgz s3://migratefolder/temp/
upload: ./abc.tgz to s3://migratefolder/temp/abc.tgz

 

Download file from S3 to Ec2

Repeat the aws configure step, and download the file with corresponse command.

[ec2-user@ip-xxx-xx-xx-xxx html]$ aws s3 cp s3://migratefolder/temp/abc.tgz abc.tgz

 

Reference

http://docs.aws.amazon.com/cli/latest/reference/s3/cp.html

Transfer files from EC2 to S3

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.