Skip to content

Build and deploy infrastructure on AWS to host a static website on S3 with custom domain, SSL and CloudFront CDN

License

Notifications You must be signed in to change notification settings

run-serverless/s3-hosting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

S3 Hosting Setup

Deploy infrastructure to host a static website on AWS S3 using the Serverless Framework V3.

Includes setting up:

  • S3 bucket to host the website
  • CloudFront (CDN) distribution to serve the website
  • SSL certificate for the website
  • Everything configured using custom domain name

Domain name must be registered and managed in Route 53.

Prerequisites

  • AWS account
  • Domain name registered in Route 53 with a Hosted Zone
  • AWS CLI installed and configured with credentials
  • A centralised Serverless Framework deployment S3 bucket using the format <aws-account-id>--serverless-deploys

Replace <aws-account-id> with your AWS account ID.

Installation

Install the Serverless Framework and application dependencies.

npm install

Usage

Deploy Infrastructure

npx serverless deploy --param="domain=<domain-name>"
  • Replace <domain-name> with the domain name, i.e. my-project.com

Note: The SSL certificate requires manual validation via DNS. This must be done via the AWS Console in the Certificate Manager in N. Virginia (us-east-1) region. Follow the instructions to add CNAME records to the domain. Deployment will pause until the certificate is validated. This might take 5 minutes or more.

Do this when the CLI shows:

Creating CloudFormation stack (2/4)

Remove Infrastructure

serverless remove

Warning: This will remove all resources created by the project and take down your website.

About

Build and deploy infrastructure on AWS to host a static website on S3 with custom domain, SSL and CloudFront CDN

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published