Shiva Sai Case study · P2
P2 Case study · app.ju25.uk

Container Delivery Control Plane

A Java service delivered to ECS Fargate by a pipeline that releases exactly the image it scanned, proves which commit is live, and recovers on its own when a release is broken. It ships with its own read-only operations interface.

Role
Sole engineer: service, container, infrastructure, pipeline, interface, operation
Built
Deployed and drilled on 4 December 2026 in ap-south-2
Stack
Java 21, Spring Boot 4, Maven, React and TypeScript, Docker, ECR, ECS Fargate (ARM64), ALB, ACM, CloudWatch, Terraform, CloudFormation, GitHub Actions, Trivy
Links
Control plane · /api/info · Repository · Evidence
01 Problem and goal

"Deployed" is not the same as "working"

A pipeline can go green while the old version still answers, while a tag points at a different image than the one scanned, or while a crashing release slowly takes the service down. At work I see the cost of that ambiguity across many services. This project removes it for one.

Engineering objective

Build once, scan once, and release that artefact by digest. Make the running commit observable from outside, and make the run fail if it is wrong. Recover from a bad release without a person racing the clock.

Constraints

A personal AWS account on a Free plan, so the design had to keep costs low: no NAT gateway, no EKS control plane, one small task.

02 Architecture

Merge to running task, in one picture

A merge to main is tested, built, smoke tested and scanned, pushed to Amazon ECR and released by digest to one ARM64 task on ECS Fargate. Visitors reach the task over HTTPS through a load balancer. Logs and metrics go to CloudWatch.
Delivery path (top) and request path. Network: two public subnets in two zones; the task's security group admits port 8080 only from the load balancer's security group.
ComponentConfigurationSource
VPC10.40.0.0/16, two public subnets, internet gateway, no NAT gatewaynetwork.tf
Load balancerHTTPS 443 with ELBSecurityPolicy-TLS13-1-2-2021-06, HTTP 80 redirects, target health on /ready every 15 salb.tf
ECS serviceFargate, ARM64, 256 CPU units and 512 MiB, circuit breaker with rollback, 100 to 200 percent during deploymentsecs.tf
ECRImmutable tags, scan on push, lifecycle policyecr.tf
CloudWatchLog group kept for 7 days; dashboard with CPU, memory, requests, 5xx, p95 latency, healthy targetsobservability.tf
03 Design decisions

Decisions, with the alternative that lost

ADR 0001Deploy by image digest

The task definition names repository@sha256:…, the bytes Trivy scanned. A tag cannot be moved under it.

Lost: deploying a tag such as latest or the version, which is readable but mutable.

ADR 0002ECS Fargate

No nodes to patch, no control plane fee, native ALB and circuit-breaker integration.

Lost: EKS, which matches my OpenShift work but costs about USD 73 a month before running anything.

ADR 0003ALB as the stable endpoint

Tasks get new IPs on every release. The ALB keeps one name, ends TLS and only routes to ready targets.

Cost: about USD 25 a month at list price with its two public addresses, even when the service is stopped.

ADR 0004One task

Enough to prove the delivery mechanics; deployments still overlap old and new tasks.

No availability-zone redundancy. Raising the count is a variable change.

ADR 0005Public subnets, no NAT gateway

The task needs outbound HTTPS to ECR and CloudWatch; a NAT gateway would cost more than everything else.

The task has a public IP, but its security group admits only the load balancer. VPC endpoints are the paid alternative.

ADR 0006Serve the interface from the service

The React build is copied into the Spring Boot jar in a Node stage of the same Dockerfile. One image, one release, one rollback.

The image build is a little longer; the API stays unchanged.

Read the ADRs

04 The container

Small, unprivileged and read-only

  • Three-stage build: Node for the interface, Maven for the jar, then a JRE image. Base images are pinned by digest.
  • Spring Boot layered jar, so dependency layers are reused between releases.
  • Runs as UID 10001 with readonlyRootFilesystem, all Linux capabilities dropped and only /tmp writable.
  • JVM capped at 60 percent of memory, serial GC, and the process exits on out-of-memory so ECS replaces it.
  • Container health check on /health; the load balancer uses /ready.
# Task definition (excerpt, ecs.tf)
user                   = "10001"
readonlyRootFilesystem = true
linuxParameters        = { capabilities = { drop = ["ALL"] } }
healthCheck = {
  command     = ["CMD-SHELL", "wget -qO /dev/null http://127.0.0.1:8080/health || exit 1"]
  interval    = 15
  startPeriod = 180
}
runtime_platform { cpu_architecture = "ARM64" }
05 Delivery pipeline

Source → tests → build → scan → ECR → ECS → verify

StageWhat happensWhat can fail, and the response
Testsmvn verify (unit and integration), interface lint, type check, tests and buildA failing test stops everything before an image exists
BuildNative ARM64 build on ubuntu-24.04-arm, commit baked inA build error stops the run
Smoke testThe image runs read-only, non-root, at 0.25 CPU; health, readiness and info are checkedAn image that cannot start read-only never ships
ScanTrivy: fixable HIGH or CRITICAL vulnerabilities and secrets fail the runThe first real run failed here; fixed by patching base packages
Approvalproduction environmentNothing reaches AWS without it
ECRThe saved, scanned image is pushed with the commit as an immutable tagA tag collision is refused by ECR
ECSA new task definition revision is pinned to the digest; a rolling update followsThe circuit breaker rolls back; the script fails if the wrong revision is primary
Verifyverify_app.py: health, ready, version and commit, headers, 404, HTTP redirectRetried, then the run fails and the logs are printed

Separate workflows cover rollback (any earlier commit's image, approved), stop and start (desired count 0 or 1, with checks), and Terraform plan, apply and destroy.

06 IAM and security

Boundaries at every layer

  • Identity. GitHub OIDC with plan, apply and deploy roles from a CloudFormation bootstrap. The deploy role can push to one repository, register this family and update this service, plus iam:PassRole for the two task roles only.
  • Network. Only 80 and 443 reach the load balancer, only the load balancer reaches 8080, and the task's outbound traffic is limited to 443.
  • Application. Read-only endpoints (a POST gets 405), no stack traces, security headers on every response, CORS for /api/info and /health limited to the portfolio origin.
  • Interface. It shows only what is safe to publish. Cluster and task identifiers are reduced to names and short IDs, and the account ID never appears. It has no stop, start, deploy or rollback buttons: those stay in approved workflows.
  • Pipeline logs are public, so scripts print revision numbers, never ARNs, and the account ID is masked.
07 Reliability

Health, readiness, rollback and roll-forward

MechanismQuestion it answersWho acts
/health (liveness)Should this process be restarted?ECS container health check replaces the task after 3 failures
/ready (readiness)Should it receive traffic?The load balancer routes only to healthy targets (2 passes in, 3 failures out)
Deployment circuit breakerIs the new revision failing to start?ECS rolls back to the last working revision
Release verificationIs the expected commit the one answering?The pipeline fails the run
Rollback workflowWas a working release wrong for users?An approved run re-releases an earlier digest
Graceful shutdownDo in-flight requests finish?Spring drains for up to 20 s; the target deregisters in 20 s
08 Observability

RED for the service, USE for the task

CloudWatch receives free ECS and load balancer metrics and structured ECS-format logs. The interface adds live, in-process readings (requests, status classes and latency since the task started, JVM heap, container memory) and labels them as such. CloudWatch figures that the public cannot query are shown as recorded snapshots with their time window.

Recorded, 4 Dec 2026 06:00 to 08:00 UTCReading
Memory, average and maximum19.0% and 22.7%
CPU, average and maximum4.6% and 99.7% (start-up of the JVM)
Requests through the load balancer237
Response time, p950.065 s
5xx from the load balancer24, all while the service was deliberately stopped
09 Operations interface

From a JSON reply to a control plane

https://app.ju25.uk/ used to answer with a JSON object. It now opens a React and TypeScript interface served by the same Spring Boot process: an overview of identity and health, release history, the pipeline stage by stage, the container configuration, live and recorded metrics, and the architecture. Every panel says whether it is live, recorded, explanation or simulation.

Existing consumers are unaffected. /health, /ready and /api/info are unchanged, and a request to / that does not ask for HTML still gets the original JSON.

Open the control plane

10 Evidence

Recorded on 4 December 2026 (UTC)

  1. 06:35First validation failed #47282490657image scan and ShellCheck findings; fixed before anything shipped
  2. 06:42Terraform apply #4728337095128 added
  3. 06:49Release 1.0.0 #47284392162c51f66a · sha256:255703a9…
  4. 06:58Release 1.1.0 #4728548743482d482e · sha256:81530c31…
  5. 07:04Rollback to 1.0.0, roll forward at 07:08 #47286330112both verified by commit
  6. 07:20Stop and start with checks #472884365450 tasks and /ready 503, then 1 task and 200
  7. 07:23Broken release drillECS rolled back on its own by 07:35; 66 of 66 readiness probes succeeded throughout
  8. 08:01Drift fixed; apply shows no changes #472939886190 added, 0 changed, 0 destroyed
11 Trade-offs and limits

What I would say in a design review

  • One task in one region is not highly available. The design shows the mechanics, not the redundancy.
  • The automatic rollback took about 11.5 minutes, because ECS waits through the 180-second grace period and the failure threshold. A faster signal would need tuning or a canary.
  • There are no alarms or paging; a human has to look.
  • The load balancer bills even when the service is stopped.
12 Future work

How it would grow

  • Two tasks across both zones, and target tracking on CPU.
  • CloudWatch alarms on 5xx and unhealthy hosts, wired to the circuit breaker's alarm-based rollback.
  • Blue/green with CodeDeploy, or weighted target groups for a canary.
  • VPC endpoints and private subnets once the budget allows.
  • An image signature (cosign) verified before release.