Chore: Add status field, which allows to wait for specific status #408
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue & Steps to Reproduce / Feature Request
Currently, using
wait_for: FULLY_DEPLOYED
field onenv0_environment
resource, has a specific issue:If environment fails to deploy on initial
terraform apply
, it'll get tainted. This means that on the nextterraform apply
, the environment will be destroyed and redeployed. If the user decides toterraform untaint
the resource, then the environment resource would not detect any change on the nextterraform apply
, and therefor will not redeployTainting happens by the terraform SDK, and this behaviour cannot be changed as long as a multi-step create fails.
If we do not throw an error on deployment failure - then the TF code will continue deploying other dependant resources as though nothing's happened. Also, on subsequent
terraform apply
s, the environment resource will not redeployIf we do not store this environment in state, then it'll just become unmanaged, and the next
terraform apply
will create another environmentSolution
This PR proposes a partial solution for the issue: It helps TF realise that a redeploy is needed if a deployment has failed.
This PR introduces a new field to the environment resource:
status
. Users have to addstatus: "ACTIVE"
to the environment resource, alongsidewait_for: "FULLY_DEPLOYED"
In conjunction with auto-untainting using env0 custom flows, the behaviour here would be as expected:
If initial environment deployment fails, the
terraform apply
will fail. The nextterraform apply
would trigger a redeploy