Problem
When utilizing the TFE provider to manage the many resources supported by Terraform Enterprise or Terraform Cloud, there may be situations where a previously applied workspace begins reporting that new resources need to be created even though they were previously applied and are currently showing on the state file. In these situations you may see the following error.
Error: Error refreshing workspace tfe-test for organization hashicorp: resource not found
on main.tf line 1, in resource "tfe_workspace" "tfe-test":
4: resource "tfe_workspace" "tfe-test" {
Prerequisites
- Using the TFE Provider
- Authorized by a User/Team/Org Token
Cause
- Terraform tries to recreate these objects because the Terraform API token being used by the API provider is no longer valid or does not have the proper permission scope applied.
Solutions
- Ensure that the API token is valid for the target resources.
- Create a new API token with the appropriate scope for use.
Outcome
Once the API token is updated and confirmed valid for the TFE provider resources, the runs should complete successfully.
Additional Information
-
TFE Provider - Documentation
- API Token - Documentation
- TFC API Authentication - Documentation