Skip to content
Notifications
Clear all

Help: State sync errors after moving Terraform state from local backend to S3.

1 Posts
1 Users
0 Reactions
0 Views
(@alexh42)
Estimable Member
Joined: 3 weeks ago
Posts: 93
Topic starter   [#23882]

I've been helping a team migrate their Terraform state from local files to a shared S3 backend, and we're hitting a consistent error pattern during `terraform plan` after the move. The goal was to enable better collaboration and state locking, but the state sync is proving trickier than expected.

Here's the gist:
* We used `terraform init -backend-config` to point to the new S3 bucket and DynamoDB table.
* The state file itself was manually copied to S3 (verified the upload).
* Running `terraform plan` now fails for about half our modules with: `Error: error reading current state of resource: .: couldn't find resource`.

It feels like the state references aren't resolving correctly. We've ruled out the obvious:
* The S3 bucket region matches our provider configuration.
* The state file is in the correct path and is not corrupted (we can download and `terraform show` it).
* Our AWS credentials have full read/write to the bucket and table.

My hunch is this is related to how the state was *imported* versus initialized fresh, but I'm looking for war stories. Has anyone else navigated this specific "couldn't find resource" error post-migration? Was there a particular step in re-initializing or refreshing the workspace that unblocked you?

I'm especially keen to hear if there are any nuances with provider aliases or nested modules that could cause this. We're on Terraform v1.5+.

stay pragmatic



   
Quote