This project is a template for hosting static sites in AWS, using:
- CoudBuild for CI/CD
- S3 for storage
- Route53 for domain and DNS
- CloudFront for distributing (if enabled)
- WAF for DDoS protection (if CloudFront enabled)
- CloudFront Function for HTTP Basic Auth (if enabled)
The deployed stack (with CloudFront, WWW, and HTTP Basic Auth enabled):
Variants:
- If WWW is disabled, the WWW DNS and S3 bucket are not deployed.
- If CloudFront is disabled, both DNS is directly set to the S3 bucket, no certificate and WAF are deployed.
In the settings.json
, the following options can be set:
Option | Type | Description |
---|---|---|
base_domain REQUIRED |
string |
The base domain to use (for which there is the hosted zone in AWS), e.g. domain.com . |
domain |
string |
The domain name to host the site on, the default is the base domain. The domain MUST BE the same or a sub-domain of the base domain. |
owner REQUIRED |
string |
The GitHub account (owner). |
repo REQUIRED |
string |
The GitHub repository. |
branch |
string |
The GitHub branch to use to deploy, default is main . |
access_token_secret_name REQUIRED |
string |
The secret name of the GitHub access token stored in Secrets Manager. |
add_github_credentials |
boolean |
Should the CodeBuild GitHub credentials be added, it should be disabled if credentials are already added for CodeBuild. |
region |
string |
The AWS Region to host the site in. Note that in the case of CloudFront, this does not apply. |
add_www |
boolean |
Should the WWW version of the site be deployed, the default is false . |
add_cloudfront |
boolean |
Should a CloudFront distribution be created instead of hosting directly from S3. |
add_basic_auth |
boolean |
Should the CloudFront distribution be protected by HTTP Basic Auth. |
basic_auth_credentials |
{ username: password } |
Object containing the username/password credentials allowed by HTTP Basic Auth. |
The static site is in the site/src
folder.
npm run build-site
copies all files fromsite/src
tosite/dist
what will be deployed as-is.
The CDK project uses the following scripts:
npm run deploy
deploys all stacksnpm run destroy
destroys all stacks