Skip to content

Instantly share code, notes, and snippets.

@hirofumihida
Last active September 21, 2018 07:42
Show Gist options
  • Save hirofumihida/7efc7d739fa93338828ce8634eb89d45 to your computer and use it in GitHub Desktop.
Save hirofumihida/7efc7d739fa93338828ce8634eb89d45 to your computer and use it in GitHub Desktop.
Copy files from S3 to EC2

EC2 info

  • ubuntu

Direction

  • Install pip3 & awscli
sudo apt-get install python3-pip
sudo pip3 install awscli
  • get access key & secret key
  1. open IAM
  2. choose user has S3 access permissions like "AmazonS3FullAccess"
  3. open security credencials tab
  4. create access key
  5. copy access key id & secret key
  • set variables
export AWS_ACCESS_KEY_ID=hoge
export AWS_SECRET_ACCESS_KEY=fuga
  • make directory (if needed) & copy files
aws s3 sync s3://{bucket-name} .

download: s3://{bucket-name}/vertica-9.1.1-0.x86_64.RHEL6.rpm to ./vertica-9.1.1-0.x86_64.RHEL6.rpm
download: s3://{bucket-name}/vertica-console-9.1.1-0.x86_64.RHEL6.rpm to ./vertica-console-9.1.1-0.x8
6_64.RHEL6.rpm
  • delete access key if it temporary use.

  • additional

"aws s3 sync" can copy files from ec2 to s3 with same way. Following command makes copying all files in current folder to S3 bucket.

aws s3 sync . s3://{bucket-name}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment