This approach describes the static website using two separate CloudFormation stacks:
- A
storage
stack, which contains the S3 bucket that contains the content of your website, and related policies; this can be deployed to any region - A
distribution
stack, which contains the CloudFront distribution, Lambda@Edge functions, SSL certificate and related resources; this is always deployed tous-east-1
- S3 bucket, where your website content is uploaded
- Origin Access Identity (OAI) in CloudFront
- S3 bucket policy that gives the OAI permission to read from the bucket
Service
is the service name of the website, used as the base name of all resourcesStage
is used as a suffix to differentiate between environments
BucketName
, the name of the bucketBucketDomainName
, the (regional) domain name of the bucketOriginAccessIdentity
, the name of the OAI
This template uses the AWS::Serverless
transform, so that we can make use of the AWS::Serverless::Function
resource type.
- CloudFront distribution
- SSL certificate that covers the root domain and the www domain using subject alternative names
- Route53 record sets (up to 4)
- Lambda@Edge functions (up to 2)
- IAM role to run the Lambda functions
- a bucket for CloudFront logging
Service
is the service name of the website, used as the base name of all resourcesStage
is used as a suffix to differentiate between environmentsDomainName
is the root domain name to use for the website
Subdomain
is the child domain to create under the root domain name,www
by default
DomainRedirectMode
instructs the template how to configure domain name redirects (see below)CertificateValidationMethod
can be eitherDNS
(the default) orEMAIL
to trigger one of ACM's validation optionsIndexDocument
specifies the filename of objects to serve as directory-level index files,index.html
by defaultRoute53HostedZoneId
must be determined manually and passed inOriginBucketDomainName
is the domain name of the bucket created in the storage stack and output asBucketDomainName
OriginAccessIdentity
is the value output from the storage stack asOriginAccessIdentity
to grant access to the origin bucket
If you use the npm
command wrapper scripts, then the last two parameters will be automatically retrieved from the deployed corresponding storage stack.
For more information about these parameters and how to use them, see Configuration.
DistributionDomainName
is the native CloudFront distribution DNS name, you will need this if you are hosting DNS outside of Route53LogsBucketName
is the name of the bucket to which CloudFormation access logs are written