Introduction
Problem
Sometimes users can see "Not Found" error when navigating to the Variables section of their HCP Terraform workspace:
Cause
This issue could be seen in a HCP Terarform workspace provisioned by No-Code module
The issue occurs due to one or a combination of the following factors:
-
Deletion of the No-Code module's latest version from the HCP Terraform UI
-
Deletion of the VCS repo based on which is created the No-Code module
Note that there is a dependency between the VCS repo, the No-Code module, and the HCP Terraform workspace, provisioned from that No-Code module. Any breaking change in the VCS repo or the No-Code module will have a direct effect on the HCP Terraform workspace.
Solution 1:
This solution will be applicable if you do NOT have anything important in the state file and you don't mind starting again.
If this is the case - delete the HCP Terraform workspace and provision a new one with the same No-Code module.
Solution 2:
This solution will be applicable if you want to use the existing state file in a brand new workspace.
Below are the steps that can help you accomplish this task:
- Go to the affected workspace >> "States" >> select latest State file >> click on "Download" button
- Delete the workspace
- Delete the No-code module
- Restore the tag in the VCS repo (applicable if the VCS was deleted, too)
- Publish the No-Code module again
- Provision a workspace using the no-code module and make sure you click on manual apply (in this way you can discard the first run and push the old state file)
- Create an empty directory on your local computer
- Configure authentication in HCP Terraform as described here.
- Add "main.tf" file with the following content:
terraform {
cloud {
organization = "georgiman-tfc4b"
workspaces {
name = "random-pet-nocode-1"
}
}
} - Place the downloaded state earlier into the same directory together with "main.tf"
- Make sure the state name is "terraform.tfstate"
georgiman@georgiman-C02Z82YVLVDQ cli $ ls -l
-rw-r--r-- 1 georgiman staff 123 Apr 1 14:05 main.tf
-rw-r--r--@ 1 georgiman staff 667 Apr 1 14:10 terraform.tfstate
georgiman@georgiman-C02Z82YVLVDQ cli $ - Execute "terraform init"
georgiman@georgiman-C02Z82YVLVDQ cli-test (main) $ terraform init
Initializing Terraform Cloud...
Do you wish to proceed?
As part of migrating to Terraform Cloud, Terraform can optionally copy your
current workspace state to the configured Terraform Cloud workspace. Answer "yes" to copy the latest state snapshot to the configured
Terraform Cloud workspace.
Answer "no" to ignore the existing state and just activate the configured
Terraform Cloud workspace with its existing state, if any.
Should Terraform migrate your existing state?
Enter a value: - Type "yes", and the state file should be pushed to the new workspace.
- Go to the "States" menu in your workspace and make sure the State is there.
- Go to "Runs" and trigger a new run from the UI.
- The plan should return "No changes"
Additional Information
If you have any questions, please reach out to HCP Terraform support by submitting a ticket via our support portal.