Skip to content

spineo/rgbutterfly-site

Repository files navigation

rgbutterfly-site

RGButterfly Logo The iPhone App to Find Paint Swatches Associated with Areas in a Photo

Syncing Content with AWS

This Web site is currently hosted on AWS Amazon. It uses S3 for content and Route 53 for DNS management. I personally found this solution to be the most versatile and cost-effective for storage, hosting, and DNS management. Below are the steps for easily syncing content between the AWS S3 bucket and locally.

Requirements: AWS (i.e., LightSail) Account, Python 2.7 or higher, and setup completed in the AWS Dashboard. For instructions on setting up DNS Hosted Zone (Route 53 Dashboard) and a Bucket with starter content (S3 Dashboard) visit the AWS site.

Mac OS (UNIX) Setup

Installing PIP (check first if available)

  • cd /tmp; curl -O https://bootstrap.pypa.io/get-pip.py
  • python get-pip.py --user
  • export PATH=~/Library/Python/2.7/bin:$PATH (or correct version/location). Might want to add the export statement in the .bashrc)
  • pip install --user --upgrade awscli
  • mv get-pip.py ~/Library/Python/2.7/bin (or remove, as probably wont need this any longer)

Setting up the AWS Configuration

  • If not done, clone your initial empty, except perhaps for the README.md, project (i.e., git clone https://github.com/spineo/rgbutterfly-site.git) and cd into that site
  • Go to your AWS dashboard and, under your account section drop-down, click on My Security Credentials
  • Click on Access Keys to uncollapse that section and the Create New Access Key button to generate a Access Key ID and Secret Access Key)
  • Back on the shell window, run aws configure and enter the Access Key ID and Secret Access Key created earlier. Make sure that you also specify the correct Default region name (i.e., us-east-1 or whatever region you are hosted under) and leave the Default output format set to "None" for now

Using the AWS CLI

  • The first thing you will need is your site bucket name. This can be obtained from your AWS S3 dashboard
  • You will want to initially sync the starter content from S3 locally (where the project was cloned) by running aws s3 sync s3://bucket-name/ . (might consider setting up a sourced variable for the bucket name such as 'S3_URL=s3://bucket-name')
  • Preview any changes using a Content Management System (CMS) or browser (i.e., * file:///git-local-path/some-file.html)
  • Next, make sure you add/commit and push content to GitHub (i.e., git add * and git commit *)
  • To upload changes or new content run aws s3 cp local-dir-or-file $S3_URL/local-dir-or-file
  • To delete a file run aws s3 rm $S3_URL/some-file

References