Support for provisioners in removed
blocks
#35230
Merged
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.
During the apply phase, we'll check if there are provisioners either in the matching resource block or the matching removed block -- whichever of the two is present -- and execute the destroy-time subset of them either way.
This also establishes a standard way to attach a removed block to a NodeResourceAbstract when one is defined, which is likely to be useful for supporting other resource-related meta arguments in removed blocks in future.
References within the destroy provisioner will be limited in scope just as if it were written within the original
resource
block, meaning that onlycount.index
,each.key
, andself
will be valid identifiers. Terraform will not be able to validate wethercount.index
oreach.key
will be valid beforehand, because the instances being destroyed could technically have either if the configuration had been changed betweencount
andfor_each
and failed to delete, so it is up to the user to ensure any references to those values are correct for the instances being destroyed.If the user specifies
destroy = false
in theremoved
lifecycle
, then the provisioner will not be be executed, as there is nodestroy
step during which to execute it.Closes #34711
Closes #13549