terraform
terraform copied to clipboard
`terraform output` causes `Error: could not read state version outputs` on fresh project
Terraform Version
1.3.2
Terraform Configuration Files
# none
Debug Output
nothing special
Expected Behavior
│
│ The state file either has no outputs defined, or all the defined outputs are empty. Please define an output in your configuration with the `output` keyword and run `terraform refresh` for it to
│ become available. If you are using interpolation, please verify the interpolated value is not empty. You can use the `terraform console` command to assist.
╵
Actual Behavior
│ Error: could not read state version outputs: resource not found
│
│
Steps to Reproduce
terraform {
cloud {
organization = "org"
workspaces {
name = "something"
}
}
}
then
terraform output
Additional Context
No response
References
No response
Suggestion:
See https://github.com/hashicorp/terraform/blob/main/internal/cloud/state.go#L412-L422
Instead of throwing an error it should be (nil, nil)
returned.
:wave: Hi Piotr!
Thanks for submitting this issue. Most if not all of TFC's endpoints return 404s if either the user is not authorized or the resource itself was not found, see status code table for Show Current State Version Outputs for a Workspace. Unfortunately the client is unable to make this distinction, so we couldn't necessarily ignore a "not found" error here and return nil, nil
.
Hopefully this clears things up for you! :smile:
@sebasslash Ok, but there is still a bug: TFC behaves differently than Terraform without TFC when I run terraform output
. It breaks my pipelines when I call terraform output
after terraform plan
for fresh projects without a stored state.
Is there any possibility to create a state version with Terraform just after a new workspace is created? I don't see anything like that in a documentation for terraform-provider-tfe