This approach describes the static website using two separate CloudFormation stacks:
- A
storagestack, which contains the S3 bucket that contains the content of your website, and related policies; this can be deployed to any region - A
distributionstack, 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
Serviceis the service name of the website, used as the base name of all resourcesStageis 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
Serviceis the service name of the website, used as the base name of all resourcesStageis used as a suffix to differentiate between environmentsDomainNameis the root domain name to use for the website
Subdomainis the child domain to create under the root domain name,wwwby default
DomainRedirectModeinstructs the template how to configure domain name redirects (see below)CertificateValidationMethodcan be eitherDNS(the default) orEMAILto trigger one of ACM's validation optionsIndexDocumentspecifies the filename of objects to serve as directory-level index files,index.htmlby defaultRoute53HostedZoneIdmust be determined manually and passed inOriginBucketDomainNameis the domain name of the bucket created in the storage stack and output asBucketDomainNameOriginAccessIdentityis the value output from the storage stack asOriginAccessIdentityto 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.
DistributionDomainNameis the native CloudFront distribution DNS name, you will need this if you are hosting DNS outside of Route53LogsBucketNameis the name of the bucket to which CloudFormation access logs are written