Skip to content

replace_triggered_by doesn't report error if given attribute references don't exist #36740

Open
@ellisonch

Description

@ellisonch

Terraform Version

Terraform v1.11.2
on linux_amd64

Terraform Configuration Files

resource "null_resource" "r1" {
}

resource "null_resource" "r2" {
    lifecycle {
        replace_triggered_by = [null_resource.r1.foo.bar.baz[0].bif] # does not error, but should
        # replace_triggered_by = [null_resource.r3] # correctly reports error
    }
}

Debug Output

none

Expected Behavior

I expect the configuration above to yield an error. null_resource.r1.foo.bar.baz[0].bif is not a real attribute reference.

Actual Behavior

$ terraform apply
null_resource.r1: Refreshing state... [id=1800298252482723122]
null_resource.r2: Refreshing state... [id=3647057674329973682]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Steps to Reproduce

  1. terraform init
  2. terraform apply

Additional Context

Since replace_triggered_by is expecting a list of resources or attributes, I'd expect that it would check that those references at least were valid references. It's extremely easy to make a mistake here (e.g., forgetting [0], or a typo, etc) and for a resource not to get replaced because of that typo.

References

No response

Generative AI / LLM assisted development?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnewnew issue not yet triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions