Development
Local development guide for the RawStack Infrastructure component.
Working with the infrastructure locally
The infrastructure project is a standard TypeScript-based AWS CDK application. Local development mainly consists of editing stack definitions, configuring environment variables, synthesising CloudFormation templates, and previewing changes before deployment.
To get started locally:
cd infrastructure/aws
npm install
cp .env.dist .envThen update .env with the AWS account, region, and stack-specific configuration for the environment you want to work with.
Environment configuration
infrastructure/aws/.env holds the deployment configuration used by the CDK app.
At a minimum, you will usually configure values such as:
AWS_ACCOUNT_ID=123456789012
AWS_REGION=eu-west-1
ENVIRONMENT=dev
ENABLE_DELETION_PROTECTION=falseAdditional variables control repository names, domain settings, build paths, and application-specific configuration for the Core, Web, and Admin stacks.
Project structure
The main project structure looks like this:
infrastructure/aws/
bin/
app.ts
lib/
core-stack.ts
web-stack.ts
admin-stack.ts
domain.ts
lambda/
core-stack/
deployment-trigger.ts
web-stack/
deployment-trigger.ts
cdk.json
.env.dist
package.jsonbin/app.ts: CDK entry point that instantiates the stackslib/core-stack.ts: shared backend platform resources such as VPC, RDS, Redis, and the API servicelib/web-stack.ts: Web hosting resourceslib/admin-stack.ts: Admin hosting resourceslib/domain.ts: shared domain and certificate helperslambda/*: deployment trigger functions used by the stacks
Useful commands
npm run cdk diff: preview infrastructure changes before deployingnpm run cdk synth: synthesise the CloudFormation templatesnpm run cdk deploy --all: deploy all stacksnpm run cdk deploy core: deploy the Core stack onlynpm run cdk deploy web: deploy the Web stack onlynpm run cdk deploy admin-hosting: deploy the Admin stack onlynpm run cdk destroy --all: destroy all deployed stacksnpm run watch: compile TypeScript in watch mode
CDK bootstrap
When deploying to an AWS account and region for the first time, bootstrap CDK first:
cdk bootstrap aws://<ACCOUNT_ID>/<REGION>This creates the CDK toolkit resources needed for later deployments.
Previewing changes
Before deploying infrastructure changes, it is good practice to inspect both the diff and the synthesised templates:
npm run cdk diff
npm run cdk synthThis makes it easier to catch unintended resource creation, deletion, or replacement before applying changes to AWS.