In this example, I'll show you how to configure AWS Amplify Console using the AWS Cloud Development Kit (CDK).
This example enables the following configuration:
- Connect to the page source repository in GitHub
- Enable deployment from
master
anddev
branches - Enable feature branch preview deployments
- Deploy artifacts from source repository root and subfolders
- Configure custom domain
amplified.host
master
branch: https://amplified.hostdev
branch: https://dev.amplified.host
All this configuration is done on: lib/cdk-amplify-console-stack.ts
The sample code reads the GitHub Personal Access Token from AWS Secrets Manager. You can store the secret there, using the following CLI command:
aws secretsmanager create-secret --name github-access-token --secret-string <github-personal-access-token>
The AWS Amplify Console provides a Git-based workflow for hosting fullstack serverless web apps with continuous deployment. A fullstack serverless app consists of a backend built with cloud resources such as GraphQL or REST APIs, file and data storage, and a frontend built with single page application frameworks such as React, Angular, Vue, or Gatsby.
AWS Amplify Console supports common Single Page App (SPA) frameworks (e.g. React, Angular, Vue.js, Ionic, Ember), as well as static-site generators like Gatsby, Eleventy, Hugo, VuePress, and Jekyll.
The AWS Cloud Development Kit (AWS CDK) is a software development framework for defining your cloud infrastructure in code and provisioning it through AWS CloudFormation.
In my example we use Typescript, and the project was inited with the command: cdk init app --language typescript
In this example we use aws-amplify CDK module.
- Complete the GitHub Actions workflow
npm run build
compile typescript to jsnpm run watch
watch for changes and compilecdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with the current statecdk synth
emits the synthesized CloudFormation template