Cloudfront Deployment - GoBoundless/spar GitHub Wiki

CloudFront will turn your fast site into a really fast site. We will taking a Spar app with an S3 Deployment and adding a content delivery network on top of it. From the AWS CloudFront Console, create a new distribution with the website form of your bucket name as the origin:

cf_1_create.png cf_2_choose_origin.png cf_3_behavior.png cf_4_details.png cf_5_review.png

When the wizard closes, take note of the ID and Domain Name fields (something like E3TI48QOEX5YX7 and d242ood0j0gl2v.cloudfront.net respectively).

If you followed the S3 Deployment instructions, you have a CNAME pointing to your S3 bucket. Update that to point to your new CloudFront distribution's domain name instead.

app.example.com. IN CNAME d242ood0j0gl2v.cloudfront.net.

And update your config.yaml:

production:
  deploy_strategy: cloudfront
  aws_key: "my_access_key"
  aws_secret: "my+super+secret+access+key"
  deploy_bucket: "mysite.test.com"
  cloudfront_distribution: "distribution+id"

Now, every time you deploy, Spar will automatically issue CloudFront invalidation requests for index.html (and anything else without a hash value). CloudFront invalidations usually take around 8 minutes, but they can take quite a bit lot longer when Amazon is having problems.