This project is built and deployed to AWS by CodeBuild. Two layers:
- Terraform (
infrastructure/terraform) — CodeBuild project + IAM role, ACM cert (us-east-1), API Gateway custom domain, Cloudflare DNS, and SSM placeholders for the Cloudflare API token + Serverless Framework license key. - Serverless Framework (
serverless.yml) — Lambda functions, API Gateway REST API, DynamoDB tables, and the base path mapping onto the Terraform-owned custom domain.
Build images live in docker-node-serverless and docker-node-terraform-aws.
- S3 bucket for Terraform remote state (default
jch254-terraform-remote-stateinap-southeast-4) - S3 bucket for CodeBuild dependency cache (default
jch254-codebuild-cache) - Cloudflare zone for the apex domain (default
603.nz) with API token created - Auth0 application configured as Single Page Application with JWT Signature Algorithm = RS256
- Allowed Callback URLs, Logout URLs, and Web Origins must include the UI origin (e.g.
https://serverless-api.603.nz)
- Allowed Callback URLs, Logout URLs, and Web Origins must include the UI origin (e.g.
- shared-platform deployed (provides the
shared-platform-build-notification-formatterLambda referenced for build-status notifications)
Terraform creates these SecureString parameters with placeholder values; populate the real values once with aws ssm put-parameter ... --overwrite. The modules' lifecycle { ignore_changes = [value] } keeps subsequent applies from clobbering them:
| Parameter | Purpose |
|---|---|
/serverless-node-dynamodb-api/cloudflare-api-token |
Cloudflare API token for the Terraform cloudflare provider |
/serverless-node-dynamodb-api/serverless-license-key |
Serverless Framework v4 license key consumed by sls deploy |
Auth0 secrets are no longer stored — the authorizer verifies tokens against Auth0's public JWKS (RS256), so only AUTH0_DOMAIN + AUTH0_CLIENT_ID (both public values) are needed and they are passed as plaintext env vars by the buildspec.
All commands below must be run from the repository root. Terraform lives in infrastructure/terraform.
- Install Terraform and make sure it is in your
PATH. - Set AWS credentials via env vars (
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY),aws configure, or an attached IAM Role. - Export
CLOUDFLARE_API_TOKEN(the Terraformcloudflareprovider reads this directly).
cd infrastructure/terraform
terraform init \
-backend-config 'bucket=jch254-terraform-remote-state' \
-backend-config 'key=serverless-node-dynamodb-api' \
-backend-config 'region=ap-southeast-4'
terraform plan -out main.tfplan
terraform apply main.tfplanThe repo's infrastructure/deploy-infrastructure.bash wraps the same flow for CodeBuild.
cd infrastructure/terraform
terraform destroyThis will delete the API Gateway custom domain, ACM cert, Cloudflare DNS records, CodeBuild project, and IAM role. The Serverless Framework stack (Lambda, API Gateway REST API, DynamoDB) is owned separately — run pnpm run remove to tear that down first.
After Terraform infra is in place and SSM placeholders are populated:
- From CodeBuild: push to
master(default webhook branch). The buildspec runsterraform applythenserverless deploy. - From local: see the root README
Packaging and deploymentsection.