Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic support for provisioners in "removed" blocks #34753

Closed
wants to merge 3 commits into from

Commits on Feb 29, 2024

  1. experiments: removed_provisioners

    This new experiment keyword represents being able to declare provisioners
    in "removed" blocks, so that it's possible to retain a destroy-time
    provisioner even when the resource it belonged to is no longer declared
    in the configuration.
    
    However, that's not yet implemented as of this commit. The implementation
    associated with this keyword will follow in subsequent commits.
    apparentlymart committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    24326a2 View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2024

  1. configs: Provisioners in "removed" blocks

    When the removed_provisioners experiment is active, removed blocks
    referring to managed resources are allowed to include "connection" and
    "provisioner" blocks, as long as all of the "provisioner" blocks specify
    when = destroy to indicate that they should execute as part of the
    resource's "destroy" action.
    
    This commit only deals with parsing the configuration. The logic to react
    to this during the apply phase will follow in later commits.
    apparentlymart committed Mar 1, 2024
    Configuration menu
    Copy the full SHA
    f31f9be View commit details
    Browse the repository at this point in the history
  2. terraform: Basic support for provisioners in "removed" blocks

    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.
    
    This code is currently accessible only to modules that opt in to the
    "removed_provisioners" language experiment, and therefore only available
    in alpha releases.
    
    One known limitation and design question from this initial implementation
    is: how should each.key, each.value, and count.index behave when used as
    part of a provisioner configuration in a "removed" block? This is a tricky
    question because whereas a "resource" block allows us to determine from
    the configuration whether we're using count, for_each, or neither, removed
    blocks must accept whatever happens to be in the state and so in unusual
    cases there might even be a mixture of numeric instance keys and string
    instance keys for the same resource, making it impossible to write a
    provisioner configuration that would work with both.
    apparentlymart committed Mar 1, 2024
    Configuration menu
    Copy the full SHA
    5680477 View commit details
    Browse the repository at this point in the history