A terraform apply killed mid-run in GitHub Actions leaves behind two DynamoDB artefacts: a stale lock and a mismatched MD5 digest.
Most guides only mention force-unlock. That fixes the lock, but you'll still get "state data in S3 does not have the expected content" until you patch the digest.
This post walks through the why, the diagnosis, and the exact 7-step fix so you can recover cleanly without recreating state from scratch.
The Incident
I was rolling out ECR repositories for four microservices via a reusable Terraform module. The pipeline, a standard plan → apply workflow on GitHub Actions had been reliable for months.
One afternoon the CI runner was terminated mid-apply. The reason didn't matter much (runner preemption, timeout, OOM — pick your favourite). What mattered was the aftermath: every subsequent terraform plan failed with this:
Initializing modules... - orders_api_service_ecr_repo in ../../../modules/aws_ecr - notifications_service_ecr_repo in ../../../modules/aws_ecr - inventory_service_ecr_repo in ../../../modules/aws_ecr - gateway_service_ecr_repo in ../../../modules/aws_ecr