Simple static website management for SPA, PWA, static or JAM stack applications. Also provided a basic auth configuration and CORS management.
This application creates an S3 bucket that will contain the website content and a CloudFront distribution in front of it for caching purpose. CloudFront functions are used to provided the correct path rewrite and eventually checking a HTTP Basic auth, before request arrives to S3.
Furthermore, the application add an EventBridge rule that forward bucket's creation/deletion events to a Lambda function that automatically create invalidations on Cloudfront distribution for related paths.
Region | Deploy Link |
---|---|
eu-west-1 | ![]() |
eu-central-1 | ![]() |
us-east-1 | ![]() |
us-east-2 | ![]() |
Using the SAM CLI:
sam build
sam deploy --guided
Including in an other SAM template:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
WebsiteStatic:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: # pick a templates links from section below, based on your region
Parameters:
DomainName: "my-domain.com"
HostedZoneId: xxxxxxxxxxxxxxxxxx
AcmCertificateArn: "arn::" # need to be requested in us-east-1 region
HttpAuthUsername: demo
HttpAuthPassword: xxxxxxxxxxxxxxx
RewriteExcludeRegEx: "(^/assets/|robots\\.txt$|favicon\\.ico$|favicon\\.svg$)"
This application need some parameters when you deploy it:
-
DomainName: The domain name of website.
-
HostedZoneId: The Route53 hosted zone ID used for the domain, if empty not Route53 record will be created.
-
AcmCertificateArn: The certificate arn for the domain name provided.
-
IndexDocument: The index document.
-
ErrorDocument: The error document, ignored in SPA mode.
-
RewriteMode: The request rewrite behaviour type (only
STATIC
orSPA
value are allowed), default:STATIC
. -
RewriteExcludeRegEx: Regular expression for authentication and path rewrite exclusion, default:
(^/assets/|robots\\.txt$|favicon\\.ico$|favicon\\.svg$)
. -
CloudFrontPriceClass: The price class for CloudFront distribution, default:
PriceClass_100
.
-
HttpAuth: Enable or disable the HTTP basic auth, default:
DISABLED
. -
HttpAuthUsername: HTTP Basic Auth username.
-
HttpAuthPassword: HTTP Basic Auth password.
-
AllowedHeaders: CORS Allowed headers, default:
*
. -
AllowedMethods: CORS Allowed methods, default:
GET,HEAD
. -
AllowedOrigins: CORS Allowed origins, default:
*
. -
ExposedHeaders: CORS exposed headers, default:
ETag
.
-
BucketName: The S3 bucket name where HTML files need to be uploaded.
-
CloudFrontDistributionId: The CloudFront distribution ID in front of the S3 bucket.
-
WebsiteUrl: The website URL.
- Repository badges by Shields.io
- Infrastructure schema by Cloudcraft