Continuous deployment of SPA websites on AWS S3 with feature branches.

Author: Albert Sikkema (@albertsikkema)

If your building Single Page Apps with modern tools like grunt or webpack or whatever you run a build which outputs generated html + js + css which can be hosted on any webserver.

AWS S3 is ideal for this because it’s simple, durable and you can put CloudFront on top of it as a CDN and Route53 for DNS registration.

Here’s a script which can deploy feature branches into their own S3 bucket with DNS (subdomain) hosting via the aws cli.

This script can easily be ran on a CI like codeship to automatically deploy feature branches.

The script:

  • Extracts the feature name from the current git branch (codeship specific)
  • Creates a bucket on S3
  • Set the appropriate policy/permissions on the bucket.
  • Copies the artifacts into the AWS S3 bucket.
  • Registers the DNS in Route53 so that the feature is directly available (on a user friendly domain name)