Note to Self - Using AWS Client’s S3 Sync

December 23, 2020 note-to-self full-stack tech
Install AWS client library

This is pretty easy to do. If you use homebrew on a mac, open a terminal and type:

brew install awscli

I’m assuming that you can to apt-get install awscli on Linux, as well.

Using the Key & Secret

In: ~/.aws/config

aws_access_key_id = [KEY STRING]
aws_secret_access_key = [SECRET STRING]

Get the key and secret by

  1. logging into the AWS console
  2. going to IAM (or search if they have yet again restructured)
  3. as of this writing, it’s under IAM Resources, Users (link). Once you open users, you’ll see it. You might have to regenerate it.

Amazon says this.

Copying/Uploading to AWS S3

Command to upload it:

/usr/local/bin/aws s3 sync ~/path/to/files/to/upload s3://[YOUR BUCKET NAME] --delete --profile s3-static-upload

Using --delete keeps your directories clean. If you are mirroring a blog, and you “unpublish” a post, you need to have the static files deleted from the server, or else they will still be active and viewable by your site visitors.