terraform-provider-aws icon indicating copy to clipboard operation
terraform-provider-aws copied to clipboard

docs: `db_instance_role_association`: add `replace_triggered_by` to example config

Open justinretzolk opened this issue 5 months ago • 1 comments

Description

I wrote quite a long comment on the referenced issue that gives more detail as to what's going on here. The tl;dr is:

  • You can use a known, static string for aws_db_instance.example.identifier
  • Since it's known, if aws_db_instance.example is recreated, Terraform has no reason to recreate the aws_db_instance_role_association, since the db_instance_identifier is unchanged
  • On a second apply, the drift is detected/corrected

I didn't dig too far into when this became necessary, but I suspect it may have been when the id / identifier / resource_id changes happened ("Schema notes" in references).

I'm a bit on the fence on exactly how to document this. It's not required in all cases (using identifier_prefix or omitting both of those arguments negates the need), but it also might not be immediately clear that this is necessary, or exactly what is necessary (I got the "solution" wrong at first, for example). Adding the lifecycle block with a note to the example config seemed like a decent compromise.

Relations

Closes #38765

References

Output from Acceptance Testing

n/a, docs

justinretzolk avatar Aug 27 '24 17:08 justinretzolk