Module depends_on
triggers update/replacement of all datasource-dependent resources
#26383
Labels
config
explained
a Terraform Core team member has described the root cause of this issue in code
working as designed
confirmed as reported and closed because the behavior is intended
Terraform Version
Terraform Configuration Files
main.tf:
sub(1|2)/main.tf
Note that the same file is used for both submodules initially simply so that you can change one without changing the other. This is for reproduction only. The actual issue was found in a substantially more complex configuration.
Expected Behavior
An update to the
from_port
of the security group rule insub1/main.tf
should cause only one resource to be replaced.Actual Behavior
All datasource-dependent resources in the dependent module (sub2) are replaced.
Steps to Reproduce
sub1
andsub2
with identical content initially).from_port
in the security group rule ofsub1/main.tf
Result: Both the security group and security group rule of
sub2/main.tf
will be replaced, even though the data sources they depend on haven't changed and return identical data.Additional Context
This issue happens with any data source, including
aws_iam_policy_document
,template_file
, etc. that should have no external dependencies. We believe this is a problem because it means that the use ofdepends_on
on a module in conjunction with data sources will force the recreation of resources that have no changes.References
The text was updated successfully, but these errors were encountered: