Skip to content

2. CI/CD Pipeline

Time to give your service its own deployment pipeline! This is the only manual CDK deploy you’ll ever do — after this, the pipeline takes care of itself.

The pipeline is the automated system that takes your code from a git push all the way to a running service in AWS. You don’t deploy manually — the pipeline does it for you, every time.

HEMA uses a self-mutating CodePipeline — meaning the pipeline definition lives in the same repo as your code. If you change the pipeline, it updates itself. If you change your app, it deploys it. One push, everything handled.


Diagram

The flow:

  1. You push to main
  2. Synth — installs deps, runs audit + lint + unit tests, builds the app, generates CloudFormation templates
  3. Self-Mutate — if the pipeline definition changed, it updates itself first
  4. Deploy — deploys your runtime (ECS Fargate container, load balancer, gateway routes)
  5. E2E — runs Playwright tests against the live deployed environment

If any step fails, the pipeline stops. No broken code reaches production.


Your repo produces exactly two CloudFormation stacks:

StackNameWhat It ContainsWho Deploys It
CI{project}-ciThe pipeline itself (CodePipeline + CodeBuild)You (once, manually)
Runtime{project}-rtYour running service (ECS + ALB + Gateway)The pipeline (automatically)

Think of it this way: the CI stack is the factory, and the Runtime stack is the product. You build the factory once, and it produces the product on every push.


This is a one-time manual deployment from your local machine:

Terminal window
project="{service}-{component}" \
repo="{repository-name}" \
branch="main" \
environmentName="preprod" \
npx cdk deploy

Example for a PDP service:

Terminal window
project="omni-web-catalog-pdp" \
repo="omni-web-catalog-pdp" \
branch="main" \
environmentName="preprod" \
npx cdk deploy

After this, you never run cdk deploy manually again. Every push to main triggers the full pipeline.


  1. Open CloudFormation Console → both stacks show CREATE_COMPLETE
  2. Open CodePipeline Console → all stages green

The main pipeline handles main branch deployments. But what about feature branches?

Butler gives you per-branch deployments. Push a feature branch → Butler creates an isolated stack with its own ECS service, ALB, and preview URL. Merge or delete the branch → Butler tears it down automatically.

Diagram

This lets you test changes in a production-like environment before merging.


For the full technical details (pipeline permissions, build environment, Playwright integration, garbage collection), see the CI/CD Pipeline Overview reference page.