Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to transfer files between AWS s3 and AWS ec2

I am using AWS ec2 instance. On this instance I'm resulting some files. These operations are done by user data.

Now I want to store those files on s3 by writing code in user data itself.

  • So how can I store those files on s3?
  • Have any tutorials on it?
like image 430
Pravin Avatar asked Apr 09 '13 19:04

Pravin


People also ask

Can we copy folder from EC2 to S3?

After generating the Access key ID and secret access key, log into the EC2 instance using SSH and configure the access key. It will ask for an access key ID and the secret access key. Provide the credentials we just generated. Now the EC2 instance has access to upload the files on S3 using the command line interface.


1 Answers

Using the most recent AWS CLI (http://aws.amazon.com/cli/) you can use the following commands to copy files from your Ec2 Instance or even you local machine to S3 storage.

aws s3 cp myfolder s3://mybucket/myfolder --recursive 

You'll then get something like:

upload: myfolder/file1.txt to s3://mybucket/myfolder/file1.txt  upload: myfolder/subfolder/file1.txt to s3://mybucket/myfolder/subfolder/file1.txt 

If this is your first usage of the aws CLI tool then you'll need to run:

aws configure

This will ask you to enter your access key & secret along with specifying a default region.

like image 72
ajtrichards Avatar answered Oct 02 '22 16:10

ajtrichards