go-tfe
go-tfe copied to clipboard
How to to check for allowed transitions?
What is the correct way to check if a plan can be applied?
When I tried to apply the plan below it fails with transition not allowed
Here is the Plan output in json (abbreviated). This plan only had changes to output values.
{
"data": {
"id": "plan-xyz"
"type": "plans",
"attributes": {
"has-changes": true,
"status": "finished",
"resource-additions": 0,
"resource-changes": 0,
"resource-destructions": 0,
"actions": {
"is-exportable": true
}
}
}
}
Hi @dkirrane
There are a couple ways to find out if a plan can be applied. Note that the checks mentioned below are on the Run
not the Plan
.
- Check that the
Run.Actions
has it’sIsConfirmable
attribute set to true, a plan will not be applied if it is not confirmable.(https://pkg.go.dev/github.com/hashicorp/go-tfe#RunActions) - Check that the
PlanOnly
attribute of the run is false. (https://pkg.go.dev/github.com/hashicorp/go-tfe#Run) - Check that the
Run.Status
is not one of the terminal statuses e.g planned_and_finished, see docs (https://www.terraform.io/cloud-docs/api-docs/run#run-states)
Closing this issue. Please reach out if you have more questions!