Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable references are not recognised in depends_on #1598

Closed
radeksimko opened this issue Oct 17, 2023 · 2 comments · Fixed by hashicorp/terraform-schema#290
Closed

Variable references are not recognised in depends_on #1598

radeksimko opened this issue Oct 17, 2023 · 2 comments · Fixed by hashicorp/terraform-schema#290
Assignees
Labels
bug Something isn't working diagnostics

Comments

@radeksimko
Copy link
Member

image

Pretty same problem for me. It does not complain when var.tgw_id is referenced under transit_gateway_id, however it it shows error (No declaration found for "var.tgw_id") when referenced in depends_on clause.

Originally posted by @mario-nc in #1592 (comment)

@radeksimko radeksimko added bug Something isn't working diagnostics labels Oct 17, 2023
@radeksimko
Copy link
Member Author

I was able to reproduce this behaviour and I can confirm it is a bug just because Terraform CLI/Core doesn't raise it - so there's deviation.

The aws_subnet.tgw-subnet is already implied by the aws_subnet.tgw-subnet[*].id on the second line, so that entry in depends_on is not necessary. Similarly, dependency on var.tgw_id is already implied by the third line. Therefore, the whole depends_on attribute is redundant and can be removed.

That said, I have confirmed that there are valid use cases for referencing variables in depends_on although such valid use cases are relatively limited - as is the case of depends_on in general. One potential use case could involve variable validation. Therefore we'll need to relax the validation rules there by updating the schemas.


Side note: Given how often I've seen depends_on being over-used I think there is an opportunity for the extension to detect such duplication between implicit and explicit dependencies and raise these as separate diagnostics, although more advisory than as errors.

Copy link

github-actions bot commented Dec 2, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working diagnostics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants