All Projects → tobilg → serverless-aws-static-websites

tobilg / serverless-aws-static-websites

Licence: MIT license
Deploy your static websites without all the hassle on AWS with CloudFront, S3, ACM and Route53 via Serverless

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to serverless-aws-static-websites

Scar
Deploy static websites in seconds - with HTTPS, a global CDN, and custom domains.
Stars: ✭ 1,715 (+1317.36%)
Mutual labels:  route53, s3, cloudfront
Awesome Aws
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Stars: ✭ 9,895 (+8077.69%)
Mutual labels:  route53, s3
Gatsby Plugin S3
Deploy your gatsby site to a S3 bucket.
Stars: ✭ 186 (+53.72%)
Mutual labels:  s3, cloudfront
s3redirect
Turn S3 into a URL redirect website using lambda and NO database!
Stars: ✭ 31 (-74.38%)
Mutual labels:  s3, cloudfront
Confetti
🎉 A tool to help creating and deploying static sites with AWS
Stars: ✭ 96 (-20.66%)
Mutual labels:  s3, cloudfront
Terraform Aws Cloudfront S3 Cdn
Terraform module to easily provision CloudFront CDN backed by an S3 origin
Stars: ✭ 162 (+33.88%)
Mutual labels:  s3, cloudfront
terraform-aws-frontend
Collection of Terraform modules for frontend app deployment on AWS.
Stars: ✭ 31 (-74.38%)
Mutual labels:  s3, cloudfront
S3 Deploy Website
Deploy website to S3/CloudFront from Python
Stars: ✭ 26 (-78.51%)
Mutual labels:  s3, cloudfront
live-streaming-on-aws-with-mediastore
Live streaming on AWS with Amazon S3 automatically configures AWS Elemental MediaLive, Amazon S3 and Amazon CloudFront to ingest, encode, package and deliver a single source live stream through the AWS Cloud. The Solution provides 3 Encoding profiles to support 1080p through 288p HTTP live streaming (HLS) outputs.
Stars: ✭ 84 (-30.58%)
Mutual labels:  s3, cloudfront
go-localstack
Go Wrapper for using localstack
Stars: ✭ 56 (-53.72%)
Mutual labels:  route53, s3
CloudHunter
Find unreferenced AWS S3 buckets which have CloudFront CNAME records pointing to them
Stars: ✭ 31 (-74.38%)
Mutual labels:  s3, cloudfront
React Deploy S3
Deploy create react app's in AWS S3
Stars: ✭ 66 (-45.45%)
Mutual labels:  s3, cloudfront
Cyberduck
Cyberduck is a libre FTP, SFTP, WebDAV, Amazon S3, Backblaze B2, Microsoft Azure & OneDrive and OpenStack Swift file transfer client for Mac and Windows.
Stars: ✭ 1,080 (+792.56%)
Mutual labels:  s3, cloudfront
Lad
👦 Lad is the best Node.js framework. Made by a former Express TC and Koa team member.
Stars: ✭ 2,112 (+1645.45%)
Mutual labels:  s3, cloudfront
Workshop Donkeytracker
Workshop to build a serverless tracking application for your mobile device with an AWS backend
Stars: ✭ 27 (-77.69%)
Mutual labels:  s3, cloudfront
mining-camp
Easy automated configuration and deployment of Minecraft servers on AWS spot instances, featuring automatic backups and restoration using S3.
Stars: ✭ 43 (-64.46%)
Mutual labels:  route53, s3
simply-static-deploy
WordPress plugin to deploy static sites easily to an AWS S3 bucket.
Stars: ✭ 48 (-60.33%)
Mutual labels:  s3, cloudfront
Aws
A collection of bash shell scripts for automating various tasks with Amazon Web Services using the AWS CLI and jq.
Stars: ✭ 493 (+307.44%)
Mutual labels:  s3, cloudfront
react-deploy-s3
Deploy create react app's in AWS S3
Stars: ✭ 67 (-44.63%)
Mutual labels:  s3, cloudfront
cloudfront-image-proxy
Make CloudFront resize images "on the fly" via lambda@edge, cache it and persists it in S3.
Stars: ✭ 32 (-73.55%)
Mutual labels:  s3, cloudfront

serverless-aws-static-websites

Host your static website on AWS via S3, with global CDN via CloudFront, using SSL certificates provided by ACM using your own domain name!

All set up via one Serverless command and minimum manual configuration!

Architecture

Serverless static websites on AWS

What is provisioned in your AWS account?

  • A S3 bucket containing your static website
  • A CloudFront distribution for global hosting via CDN
  • A HostedZone on Route53 with A records for your domain name
  • A Lambda function for automatic SSL certificate generation via ACM for your domain name (run once upon deployment)

Preconditions

This guide assumes that you have a pre-existing domain which you want to use for hosting your static website. Furthermore, you need to have access to the domain's DNS configuration.

Also, you need to have an install of Serverless on your machine.

How-to

To use this blueprint with your own static websites, you can follow the steps below to get started.

Set up a Serverless project for your static website

There are basically two ways to get started, either use Serverless to generate a basic project structure, or use the "traditional" fork and clone mechanisms.

Use Serverless templates

The following command will create a local project structure you can use to deploy your static website in the mystaticwebsite folder relative to your current working directory:

$ sls create --template-url https://github.com/tobilg/serverless-aws-static-websites --path mystaticwebsite
Serverless: Generating boilerplate...
Serverless: Downloading and installing "serverless-aws-static-websites"...
Serverless: Successfully installed "serverless-aws-static-websites"

Hint
When using this method, Serverless is replacing the service.name in the serverless.yml file automatically with mystaticwebiste. If you want to use a different stack name, you have to replace it manually. You also need to take care of that the stack name is using only allowed characters. When using the "Fork and clone" method below, the stack name is automatically derived from the domain name and sanitized regarding the allowed characters.

Fork and clone

Once you forked the repo on GitHub, you can clone it locally via

$ git clone [email protected]:youraccount/yourrepo.git

where youraccount/yourrepo needs to be replaced with the actual repository name of your forked repo.

Install dependencies

To install the dependencies, do a

$ npm i

After that, the project is usable.

Create your static website

You can now create your static website in the src folder of your cloned repo.

Deploy

You can deploy your static website with the following command:

$ sls deploy --domain yourdomain.yourtld

where yourdomain.yourtld needs to be replaced with your actual domain name. You can also specify a AWS region via the --region flag, otherwise us-east-1 will be used.

Manual update of DNS records on first deploy

On the first deploy, it is necessary to update the DNS setting for the domain manually, otherwise the hosted zone will not be able to be established.

Therefore, once you triggered the sls deploy command, you need to log into the AWS console, go to the Hosted Zones menu and select the corresponding domain name you used for the deployment.

The nameservers you have to configure your domain DNS to can be found under the NS record and will look similar to this:

ns-1807.awsdns-33.co.uk.
ns-977.awsdns-58.net.
ns-1351.awsdns-40.org.
ns-32.awsdns-04.com.

You should then update your DNS settings for your domain with those values, otherwise the stack creation process will fail.

This is a bit misfortunate, but to the best of knowledge there's currently no other way possible if you use AWS external (non-Route53) domains. During my tests with namecheap.com domains the DNS records were always updated fast enough, so that the stack creation didn't fail.

Deployment process duration

As a new CloudFront distribution is created (which is pretty slow), it can take up to 45min for the initial deploy to finish. This is normal and expected behavior.

Post-deploy

If the deployment finished successfully, you will be able to access your domain via https://www.yourdomain.yourtld and https://yourdomain.yourtld.

This setup should give you some good PageSpeed Insights results.

Updates

For every update of your website, you can trigger a deploy as stated above. This will effectively just do s S3 sync of the src folder.

To do a manual sync, your can also use sls s3sync. There's also the possibility to customize the caching behavior for individual files or file types via the serverless.yml, see the s3sync plugin's documentation.

As CloudFront caches the contents of the website, a Serverless plugin is used to invalidate files. This may incur costs, see the docs for more info.

You can run sls cloudfrontInvalidate to do a standalone invalidation of the defined files in the serverless.yml.

Removal

If you want to remove the created stack, you will have to delete all records of the Hosted Zone of the respective domain except the SOA and NS records, otherwise the stack deletion via

$ sls remove --domain yourdomain.yourtld

will fail.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].