vdelacou / iblis-deploy-static

Deploy Multi-Language Static HTML on CDN. With Serverless Framework and AWS CloudFront. Delete Cache on redeploying and force redirect according to browser language

Home Page:https://medium.com/@vdelacou/deploy-multi-language-static-html-on-cdn-a5dd7e229146

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IBLIS-DEPLOY-STATIC

Deploy Multi-Language Static HTML on CDN.

With Serverless Framework and AWS CloudFront. Delete Cache on redeploying and force redirect according to browser language

Repository for this medium article: Deploy Multi-Language Static HTML on CDN

Please read the article if you have any questions

Why

With the rise of Single Page Application (SPA), the use of a Content Delivery Network (CDN) is more than recommended. It allows us to have fast and reliable static hosting with easy HTTPS set up around the world. I love CloudFront, but I was always frustrated with 2 things, that I can do with .htaccess or Nginx configuration:

  • When I deploy a new version, I want it accessible immediately (clean server and browser cache)
  • If browser it's in French, I want to redirect the user to /fr/index.html (for example)

Features

  • Automatic S3 Bucket set-up (all object private)
  • Automatic Cloudfront set-up with policy access to the bucket
  • Set up of AWS lambda with CloudFront Egde
  • Redirect user according to browser language
  • Copy the file to S3 Bucket
  • Clean S3 Object Cache when redeploy
  • Invalidate CDN Distribution when redeploy

Library and Tools

Deploy the site in src folder

Install and follow instructions to setup serverless with AWS

Install the AWS CLI

Then Launch

git clone https://github.com/vdelacou/iblis-deploy-static

cd iblis-deploy-static

chmod +x deploy.sh

./deploy.sh

You can replace the content of the src folder with your site (HTML, CSS, JS) and also rename the project in serverless.yml (don't forget to change the lambda function languageRedirectCloudFront.js according to your need)

Deploy with BitBucket Pipelines

We add the bitbucket-pipelines.yml file for you to use the bitbucket pipleines out of the box.

Contribute

  1. Fork this repository to your own GitHub account and then clone it to your local device
  2. Make the necessary changes and ensure that the tests are passing
  3. Send a pull request

Known issues

  • None for the moment

License

Please, refer to LICENSE file

About

Deploy Multi-Language Static HTML on CDN. With Serverless Framework and AWS CloudFront. Delete Cache on redeploying and force redirect according to browser language

https://medium.com/@vdelacou/deploy-multi-language-static-html-on-cdn-a5dd7e229146

License:Apache License 2.0


Languages

Language:JavaScript 63.7%Language:CSS 25.7%Language:HTML 10.3%Language:Shell 0.3%