Luke
Luke

Reputation: 623

Terraform Remote State using incorrect file

We are using Terraform with an S3 backend via Terragrunt. Recently, someone tried to use a Terraform workspace, and subsequently deleted the workspace, not our remote state cannot find any of the outputs which are in the correct state file.

Upon looking at the debug log, I can see it looks to be pointing to the right file, but it is not picking up any of the already deployed infrastructure or outputs

Upvotes: 0

Views: 573

Answers (1)

BMW
BMW

Reputation: 45353

Terraform workspace and terragrunt using different backend key path. And if you run with terragrunt, the s3 bucket has version control enabled as default.

For example, using terraform workspace, the real *.tfstate file will be created to

s3://<nominated_backend_bucket>/env:/<workspace_name>/<tfstate_path>

But terragrunt will create the tfstate path as

s3://<nominated_backup_bucket>/<source_code_directory>/<tfstate_path>

So in most cases, they will have no chance to conflict each other.

I recommend to clean your environment and run terragrunt plan/apply again. There are some other problems more than you described in your original question and you need find out by yourself.

Upvotes: 1

Related Questions