This repo houses IaC using the CDK to deploy Amplify applications to multiple regions for testing. Cypress tests can be run locally to validate functionality of the applications deployed.
Located under /apps
:
- SSG / SSR - create-next-app (hgw-tests-cna)
- SPA - create-react-app (hgw-tests-cra)
- HTML / SSG - astro (hgw-tests-html)
Located under infra/hostingGatewayAppsCDK
. CDK to deploy /apps
to Amplify Hosting.
Located under /cypress
. End to end tests to verify the applications deployed to Amplify Hosting work as expected.
NOTE: setup.sh
is configured with default regions of us-east-2
and ca-central-1
. Update these to your preference.
- Define your AWS Account ID
export AWS_ACCOUNT_ID=<AWS_ACCOUNT-ID>
- Run
./setup.sh
OR follow the steps in Manual setup
- Set default region for CDK
export CDK_DEFAULT_REGION=us-east-2
- Define the deployment regions for this stack
export HGW_APP_REGIONS="$CDK_DEFAULT_REGION|ca-central-1"
Regions separated by pipe (|) - This stack will be deployed to ALL regions defined - Install CDK and pnpm
npm install -g aws-cdk pnpm
- Install dependencies
pnpm install
- Bootstrap regions where the stack will be deployed. Run the following command:
cdk bootstrap aws://<AWS-ACCOUNT-ID>/<AWS-REGION>
- Copy
apps.example.json
toapps.json
- Copy
infra/hostingGatewayAppsCDK/.env.example
to.env
- Generate a Github Personal Access Token for use in the next step
- Update
infra/hostingGatewayAppsCDK/.env
with environment variables
GITHUB_TOKEN=<YOUR-GITHUB-TOKEN>
GITHUB_OWNER=<YOUR-GITHUB-USERNAME>
GIT_REPO=hostingGatewayAppsCDK
- Run
pnpm run infra:deploy
- Run
pnpm run infra:destroy
NOTE: GitHub webhooks are not cleaned up after destroying. Navigate to https://github.com//hostingGatewayAppsCDK/settings/hooks to delete.