Please help fill in this template with all the details to help others help you more efficiently. Use formatting blocks for code, config, logs and ensure to remove sensitive data.
Problem: Unable to Download Terraform State File (UI + API Both Failing)
What we see in the UI
-
Under Operate → Terraform States →
<stateName>, the state is visible. -
However, there is no option to manually download the state file to validate its contents.
What we tried via API
We attempted to download the state using the Terraform State API:
curl --header "PRIVATE-TOKEN: $TF_STATE_TOKEN" \
"https://gitlab.com/api/v4/projects/<projectID>/terraform/state"
But we keep getting:
404 Not found (401 unauthorized sometimes with PAT)
Even though the state clearly exists in the project under Operate → Terraform States
Add the infrastructure-as-code or cloud-native configuration relevant to the question.
Infrastructure-as-Code
- Terraform
Question
-
Is there a specific API endpoint or parameter required to download a Terraform state file?
-
Do Terraform states stored via the GitLab-managed backend support manual download?
-
Are there permissions or access-token scopes required beyond
api?
Thanks for taking the time to be thorough in your request, it really helps! ![]()