1. A Terraform engineer is troubleshooting a situation where two resources have a dependency that cannot be expressed through attribute references. The configuration manages an AWS Lambda function and an S3 bucket policy. The Lambda reads from the bucket, but the bucket policy ARN is not directly referenced in the Lambda configuration. The engineer adds `depends_on` to the Lambda resource pointing to the bucket policy. What is a known side effect of using `depends_on` on a resource (as opposed to expressing the dependency through a reference)?
- A. Terraform will validate that the `depends_on` target exists in the real infrastructure before proceeding with the plan.
- B. Any `output` value that references the resource with `depends_on` will also inherit the dependency, potentially causing outputs to be unknown during planning.
- C. Terraform will replace the resource with `depends_on` on every plan, regardless of whether any attributes changed.
- D. When `depends_on` is used on a resource, Terraform treats all attributes of that resource as unknown during planning if the dependency has any pending changes, which can cause a more conservative and less informative plan.✓ Correct
Explanation
Option D is correct. When `depends_on` is applied to a resource (or module), Terraform cannot use its normal fine-grained dependency analysis. If the `depends_on` target has any pending changes, Terraform must treat the dependent resource's attributes as unknown during planning — because any side effect could theoretically change what values are produced. This results in a less informative plan where values show as `(known after apply)` even when they could otherwise be known. Option A is wrong — `depends_on` is purely a planning-time directive; Terraform does not pre-validate the existence of the target in real infrastructure. Option B is partially related but is specifically a behavior of `depends_on` on *modules*, not resources, and the mechanism described is not quite accurate. Option C is wrong — `depends_on` does not cause unconditional replacement; it only affects ordering and planning granularity.