You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a depends_on argument in a module definition for a module that uses the data source aws_partition, terraform plan will fail with an error due to not knowing the value until apply, like this:
The "for_each" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the for_each depends on.
terraform plan fails with 1 or more errors depending on how many times this data source is referenced.
Steps to Reproduce
terraform init -var-file=test.tfvars
terraform plan -var-file=test.tfvars -out test.tfplan
This will give you a successful plan, to see the error in action, uncomment the depends_on argument on line 30 of eks.tf and re-run terraform plan.
Additional Context
I have ran into this before with my own custom modules with the same requirements (depends_on argument in module definition, and the module using aws_partition data source), so this issue is not just with the eks module in use here.
The behavior you have described here is expected form the given configuration. Data sources using depends_on are always deferred until apply when there is a change in any of their dependencies. Because depends_on can't describe which part of the change is relevant, the entire change must be taken into account.
When you add depends_on to a module, you are effectively adding that to every object within the module. This can be a convenient shortcut in some cases, but we generally discourage using it on modules for this very reason, especially when that module contains data sources.
We use GitHub issues for tracking bugs and enhancements, rather than for questions. While we can sometimes help with certain simple problems here, it's better to use the community forum where there are more people ready to help.
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.
When using a depends_on argument in a module definition for a module that uses the data source aws_partition, terraform plan will fail with an error due to not knowing the value until apply, like this:
Terraform Version
Terraform Configuration Files
https://github.com/watsonjm/depends_on-bug
Debug Output
https://gist.github.com/watsonjm/31bdebd61e02aa05f4d4ae2374ceac9e
Expected Behavior
terraform plan should show a successful plan
Actual Behavior
terraform plan fails with 1 or more errors depending on how many times this data source is referenced.
Steps to Reproduce
This will give you a successful plan, to see the error in action, uncomment the depends_on argument on line 30 of eks.tf and re-run terraform plan.
Additional Context
I have ran into this before with my own custom modules with the same requirements (depends_on argument in module definition, and the module using aws_partition data source), so this issue is not just with the eks module in use here.
References
terraform-aws-modules/terraform-aws-eks#1753
The text was updated successfully, but these errors were encountered: