DevSecOps and CI/CD for Planned Wallet
Shipping Fast Without Breaking Production
When I pivoted Planned Wallet to AWS, my goal was simple. I wanted to be able to merge code and see it running in stage within minutes, promote to production with confidence, and keep the whole thing locked down enough that I could leave the repository public without worrying about leaking credentials or letting a bad dependency slip through.
The production footprint is straightforward. CloudFront sits in front of everything, serving the static Next.js frontend from S3 and routing API traffic through CloudFront WAF into a Golang microservice running on ECS Fargate, backed by Amazon RDS PostgreSQL. What makes it enjoyable to work on every day is the CI/CD and DevSecOps layer sitting behind it in GitHub Actions.
Catching Problems Before Merge
Every pull request goes through a gate before it can touch main. Dependabot opens weekly grouped updates for Go modules, npm packages, Python test dependencies, and GitHub Actions, which keeps things current without burying me in notifications.
To protect against supply chain attacks where a newly published package gets compromised and yanked within hours, the pull request gate runs a 5-day dependency cooldown check. A Python script diffs the lockfiles and Dockerfiles against the base branch and checks the publication timestamp of any newly added or updated dependency across npm, Go, and Docker. If a package is less than 5 days old, the build fails. Existing pinned dependencies pass right through, while anything brand new has to sit in quarantine for 5 days before it is allowed in.
From there, the pull request gate runs the Go unit tests, compiles the backend binary, runs linting and unit tests on the Next.js frontend, verifies the static export artifacts, and builds all three Docker images (backend, frontend, and local nginx gateway) to make sure nothing is broken at the container layer. Finally, it spins up the full local docker-compose stack twice and runs the Playwright and API integration test suites against both basic user mode and premium subscriber mode. If a feature breaks either tier, it never reaches main.
Guardrails on Who and What Can Deploy
Because the repository is public, deployment workflows enforce strict boundaries on identity, branches, and credentials.
First, there are no long-lived AWS IAM access keys anywhere in GitHub Secrets. Every deployment job authenticates to AWS using short-lived OIDC tokens tied to separate stage and production IAM roles.
Second, every deploy job verifies that the triggering actor is my GitHub account, and branch rules restrict where each environment can deploy from. Automated pushes to main only deploy to stage. Production deploys only happen when I manually dispatch a workflow from main or push a release tag, and even then, the workflow runs a git ancestry check to prove the tagged commit actually lives in main. Concurrency groups per environment ensure two deployments never race each other against the same ECS service or S3 bucket.
Idempotent Schema Changes in a Private VPC
Database migrations are often where fast delivery slows down or gets risky. For Planned Wallet, all schema definitions live in a single idempotent init.sql file using CREATE TABLE IF NOT EXISTS, CREATE INDEX IF NOT EXISTS, and guarded ALTER TABLE blocks. Because it is idempotent, it can be run repeatedly against stage or production without altering or corrupting existing data.
To avoid exposing RDS to the public internet or paying for a NAT Gateway just to run migrations from GitHub Actions, a deployment helper script gzip-compresses and base64-encodes init.sql and launches an ephemeral ECS Fargate task inside the VPC. The task connects to RDS over the private network, applies the SQL with ON_ERROR_STOP enabled, streams the CloudWatch logs back into the GitHub Actions job summary, and exits. If anything fails, the pipeline halts before a new backend container revision is ever deployed.
Pre-Flight Config Checks and Live Activation Validation
Before the backend pipeline builds and pushes an immutable image to ECR (tagged with the Git SHA and embedded with build metadata including the GitHub run ID, build date, SHA, and tag), it fetches the live ECS task definition from AWS and runs a pre-flight safeguard script. That script verifies that mandatory runtime flags and secrets like JWT_SECRET, EXPECTED_ORIGIN_SECRET, REQUIRE_CAPTCHA, GIN_MODE, PRODUCTION_ENV, and the database connection settings are actually present and valid for the target environment. Since the logs are public, any sensitive variable or secret ARN is masked in the console output.
On the frontend side, static assets are synced to S3 with long-lived immutable cache headers on hashed files, no-cache headers on HTML files, and an automatic CloudFront invalidation so users do not get stuck on stale markup.
On the backend side, deploying to ECS and waiting for Fargate service stability is not the finish line. Once ECS reports the service is stable, a post-deploy verification gate polls the live /api/v1/version endpoint through CloudFront and WAF for up to two minutes. It checks the JSON response until the live service returns the exact GitHub run ID, build date, Git SHA, and tag that were just built. A deployment only turns green once the new code is proven active and serving traffic through the full production edge.
Why It Works
Putting these safeguards in place took a bit of upfront scripting, but the payoff is that I do not have to think about them day to day. I can merge a change to main, let the pipeline test both subscription modes, verify the task definition, run the idempotent schema script, deploy the containers, and prove the new version is live at https://www.plannedwallet.com. That combination of guardrails and automation is what lets me move at startup speed without flying blind.