replace_triggered_by is a Terraform lifecycle setting that forces a resource replacement when selected attributes or referenced resources change. section 2.7.2
Choose the trigger scope deliberately:
- Reference a specific attribute when only that attribute should trigger replacement. section 2.7.2
- Reference a resource itself when any change to that resource should trigger replacement. section 2.7.2
- A changed aws_instance instance_type normally updates the existing machine in place; replace_triggered_by can require a new instance instead. section 2.7.2
Replacing an instance when its type changes
A null_resource records instance_type through its triggers map. The aws_instance then lists that null_resource in replace_triggered_by, coupling the variable change to instance replacement.
