Both the CDK Construct and CDK Source Code methods require some common configuration steps. Follow this guide to set up the necessary files.
Configuration Files
Create a cloudfront-hosting-toolkit
folder at the root of your CDK project and add the following files:
buildConfigurationFile.yml
: Configures the build process for your specific framework.
- A JavaScript file for the CloudFront function (e.g.,
url-rewriting.js
): Handles URL rewriting for your application.
cloudfront-hosting-toolkit.json
: Contains your project configuration.
1. Build Configuration File
Example for Vue.js:
More build configuration templates
2. CloudFront Function File
Example for Vue.js:
More CloudFront function templates
3. Project Configuration File
For GitHub-based workflow:
For S3-based workflow:
More configuration examples
Field Descriptions
Mandatory Fields
-
For GitHub workflow:
repoUrl
: The URL of your GitHub repository
branchName
: The branch to deploy
framework
: The framework used in your project (e.g., βnextjsβ, βreactβ, βvueβ)
-
For S3 workflow:
s3bucket
: The name of your S3 bucket containing the source code
s3path
: The path within the bucket where your source code is located
Optional Fields
domainName
: Your custom domain name (if you want to use one)
hostedZoneId
: The Route 53 hosted zone ID for your domain (required if using a custom domain)
Note: If you include domainName
, you must also include hostedZoneId
. These fields are used together to set up a custom domain for your website.