• Martin Atkins's avatar
    command/format: Limitation of plans.ResourceInstanceDeleteBecauseNoModule · 74af3432
    Martin Atkins authored
    This is an explicit technical debt note that our plan renderer isn't able
    to give a fully-specific hint in this particular case of deletion reason.
    
    This reason code means that at least one of the module instance keys in
    the resource's module path doesn't match an instance declared in the
    configuration, but the plan data structure doesn't retain enough
    information to know which is the first step in the path which refers to
    a missing instance, and so we just always return the whole thing.
    
    This would be confusing if we return module.foo[0].module.bar not being
    in the configuration as a result of module.foo not using "count"; it would
    be better to say "module.foo[0] is not in the configuration" instead.
    
    It would be most ideal to handle all of the different situations that
    ResourceInstanceDeleteBecauseWrongRepetition's rendering does, so that we
    can go further and explain exactly _why_ that module instance isn't
    declared anymore.
    
    We can do neither of those things today because only the Terraform Core
    "expander" component knows that information, and we've discarded that
    by the time we get to rendering a plan. To fix this one day would require
    preserving in the plan information about which module instances are
    declared, as a separate sidecar data structure from which resource
    instances we're taking actions on, and then using that to identify which
    step in addr.Module here first selects an invalid instance.
    74af3432