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
"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.
Merge to running task, in one picture
| Component | Configuration | Source |
|---|---|---|
| VPC | 10.40.0.0/16, two public subnets, internet gateway, no NAT gateway | network.tf |
| Load balancer | HTTPS 443 with ELBSecurityPolicy-TLS13-1-2-2021-06, HTTP 80 redirects, target health on /ready every 15 s | alb.tf |
| ECS service | Fargate, ARM64, 256 CPU units and 512 MiB, circuit breaker with rollback, 100 to 200 percent during deployments | ecs.tf |
| ECR | Immutable tags, scan on push, lifecycle policy | ecr.tf |
| CloudWatch | Log group kept for 7 days; dashboard with CPU, memory, requests, 5xx, p95 latency, healthy targets | observability.tf |
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
latestor 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.
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/tmpwritable. - 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" }
Source → tests → build → scan → ECR → ECS → verify
| Stage | What happens | What can fail, and the response |
|---|---|---|
| Tests | mvn verify (unit and integration), interface lint, type check, tests and build | A failing test stops everything before an image exists |
| Build | Native ARM64 build on ubuntu-24.04-arm, commit baked in | A build error stops the run |
| Smoke test | The image runs read-only, non-root, at 0.25 CPU; health, readiness and info are checked | An image that cannot start read-only never ships |
| Scan | Trivy: fixable HIGH or CRITICAL vulnerabilities and secrets fail the run | The first real run failed here; fixed by patching base packages |
| Approval | production environment | Nothing reaches AWS without it |
| ECR | The saved, scanned image is pushed with the commit as an immutable tag | A tag collision is refused by ECR |
| ECS | A new task definition revision is pinned to the digest; a rolling update follows | The circuit breaker rolls back; the script fails if the wrong revision is primary |
| Verify | verify_app.py: health, ready, version and commit, headers, 404, HTTP redirect | Retried, 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.
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:PassRolefor 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
POSTgets 405), no stack traces, security headers on every response, CORS for/api/infoand/healthlimited 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.
Health, readiness, rollback and roll-forward
| Mechanism | Question it answers | Who 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 breaker | Is the new revision failing to start? | ECS rolls back to the last working revision |
| Release verification | Is the expected commit the one answering? | The pipeline fails the run |
| Rollback workflow | Was a working release wrong for users? | An approved run re-releases an earlier digest |
| Graceful shutdown | Do in-flight requests finish? | Spring drains for up to 20 s; the target deregisters in 20 s |
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 UTC | Reading |
|---|---|
| Memory, average and maximum | 19.0% and 22.7% |
| CPU, average and maximum | 4.6% and 99.7% (start-up of the JVM) |
| Requests through the load balancer | 237 |
| Response time, p95 | 0.065 s |
| 5xx from the load balancer | 24, all while the service was deliberately stopped |
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.
Recorded on 4 December 2026 (UTC)
- 06:35First validation failed #47282490657image scan and ShellCheck findings; fixed before anything shipped
- 06:42Terraform apply #4728337095128 added
- 06:49Release 1.0.0 #47284392162
c51f66a·sha256:255703a9… - 06:58Release 1.1.0 #47285487434
82d482e·sha256:81530c31… - 07:04Rollback to 1.0.0, roll forward at 07:08 #47286330112both verified by commit
- 07:20Stop and start with checks #472884365450 tasks and
/ready503, then 1 task and 200 - 07:23Broken release drillECS rolled back on its own by 07:35; 66 of 66 readiness probes succeeded throughout
- 08:01Drift fixed; apply shows no changes #472939886190 added, 0 changed, 0 destroyed
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.
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.