Why Your Terraform State Is More Sensitive Than Your .env File
Terraform state can contain passwords, access keys, and a map of your infrastructure. Here is how I keep it out of Git, lock it in S3, and limit who can read it.
Need to change AWS infrastructure without guessing what Terraform will touch? I can help review the current stack, make the change, and check the plan before it is applied.
I read the repository and its deployment rules before editing. Resource names, state location, account boundaries, and cost limits matter more than a generic template.
The change comes with a Terraform plan and a short explanation of additions, replacements, and anything that needs a human decision.
Validation catches syntax and provider errors. The full plan catches changes validation cannot see, including resource replacement and drift.
I document the commands, state assumptions, and review steps so your team can make the next change without rediscovering them.
I wrote up how I use Claude Code with Terraform on AWS, including the context file, validation hooks, plan review, and the places where I still check everything myself.
Read my AWS and Terraform workflowWhere state lives, whether the S3 bucket has versioning on, and how locking works. Older setups lock with a DynamoDB table. Newer Terraform versions can lock in S3 itself with use_lockfile.
On a stateful resource, forces replacement is where data loss starts. Sometimes the fix is a moved block. Sometimes it is prevent_destroy and a different change.
I check that the AWS provider and modules are pinned and that .terraform.lock.hcl is committed. A new major provider version can change defaults under you.
I run terraform plan -refresh-only first. It shows what changed outside Terraform without proposing to touch real infrastructure. If the drift was intended, it goes into the code. If not, the next apply puts it back.
Wildcard actions, iam:PassRole on every resource, and trust policies that let too many principals assume a role. These pass validation and still fail a review.
Writing
Posts that sit next to this work.
Terraform state can contain passwords, access keys, and a map of your infrastructure. Here is how I keep it out of Git, lock it in S3, and limit who can read it.
Not everything needs to be serverless. I know, I know. I literally write about Lambda and API Gateway all the time. But look, sometimes you just need a single EC2 instance running your Laravel app and
My GitHub Actions pipeline for AWS Lambda and Terraform: OIDC deploys with no stored AWS keys, S3 state locking, a prod approval gate, and alias rollback.