terraform/internal/instances
Martin Atkins ec6fe93fa8 instances: Non-existing module instance has no resource instances
Previously we were treating it as a programming error to ask for the
instances of a resource inside an instance of a module that is declared
but whose declaration doesn't include the given instance key.

However, that's actually a valid situation which can arise if, for
example, the user has changed the repetition/expansion mode for an
existing module call and so now all of the resource instances addresses it
previously contained are "orphaned".

To represent that, we'll instead say that an invalid instance key of a
declared module behaves as if it contains no resource instances at all,
regardless of the configurations of any resources nested inside. This
then gives the result needed to successfully detect all of the former
resource instances as "orphaned" and plan to destroy them.

However, this then introduces a new case for
NodePlannableResourceInstanceOrphan.deleteActionReason to deal with: the
resource configuration still exists (because configuration isn't aware of
individual module/resource instances) but the module instance does not.
This actually allows us to resolve, at least partially, a previous missing
piece of explaining to the user why the resource instances are planned
for deletion in that case, finally allowing us to be explicit to the user
that it's because of the module instance being removed, which
internally we call plans.ResourceInstanceDeleteBecauseNoModule.

Co-authored-by: Alisdair McDiarmid <alisdair@users.noreply.github.com>
2021-12-13 10:03:50 -05:00
..
expander.go instances: Non-existing module instance has no resource instances 2021-12-13 10:03:50 -05:00
expander_test.go instances: Non-existing module instance has no resource instances 2021-12-13 10:03:50 -05:00
expansion_mode.go Move addrs/ to internal/addrs/ 2021-05-17 14:09:07 -07:00
instance_key_data.go
set.go refactoring: First round of ValidateMoves rules 2021-07-29 12:29:36 -07:00
set_test.go instances: Expander.AllInstances 2021-07-28 13:54:10 -07:00