Part 3 of the shorty series: one compose.yaml for the Go API, Postgres 18 and Redis 8, with a one-shot migrate service, idempotent seed data, named volumes and healthchecks. Plus the Postgres 18 volume path change and a seed that failed on the first run.
The ECS mental model in one post: what a cluster, task definition, task and service really are, how a deploy rolls, the difference between the task role and the execution role, and what Fargate costs against EC2 in Mumbai.
A first .gitlab-ci.yml for shorty, the Go URL shortener: stages, jobs, workflow rules, a Postgres service, test reports and the difference between artifacts and caches. Checked locally with gitlab-ci-local and the real job commands.
Why retries turn a small outage into a big one, and how to stop it in Go: per-attempt timeouts, full-jitter backoff, a retry budget, a small circuit breaker and a bulkhead, with tests that count the calls.
Two psql sessions against Postgres 18 to reproduce a lost update, a non-repeatable read and write skew, then fixing them with atomic updates, SELECT FOR UPDATE, REPEATABLE READ and SERIALIZABLE with a retry loop in Go.
Two branches picked the same goose migration version twice in two days. Here is what goose does with duplicate and out-of-order versions, the CI check I use to catch both before merge, and naming habits that stop it happening.
Plain depends_on only waits for a container to start, not for Postgres to accept connections. Here is how I fixed the race in a Go app's compose file with healthchecks, service_healthy and service_completed_successfully, plus a pg_isready trap I hit on the way.
Turning three copy-pasted S3 buckets into one resource with for_each, with typed variables, validation blocks, locals, outputs and a tfvars file per environment, plus why I pick for_each over count.
Turning on gitleaks for an old repo can fail every pull request because of something committed years ago. Here is how I split it into a blocking scan of the PR's own commits, a report-only history scan with a job summary, and a pre-push hook, always with --redact.
A scripts folder with two package names in one directory makes go list ./... fail, and with it go vet, go test and govulncheck. Here is how I list packages with go list -e, filter by path and pass the list through GITHUB_OUTPUT, and why I don't filter on .Error.
Methods on your own types, implicit interfaces, small interfaces like io.Reader, type switches, the nil interface trap and "accept interfaces, return structs", with runnable examples on Go 1.27 and a small io.Writer exercise.
A HeadObject size check followed by a GetObject is a race: the object can be replaced with a huge one in between. Here is how I read S3 objects in Go with io.LimitReader and one extra byte, so the cap holds no matter what the size check said.