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

fix: Fixed the for_each value depends on resource attributes that cannot be determined until apply #72

Merged
merged 2 commits into from
Jun 19, 2022

Conversation

antonbabenko
Copy link
Member

@antonbabenko antonbabenko commented Jun 18, 2022

It is still not working, and after wasting more than 20 hours on fixing #59 ... I give up (for now)...

If anyone likes challenges, please try to finish this PR.

All information and "definition of done" is modules/records/main.tf.

Huge thanks to @flora-five for figuring out the working solution.

Fixes #59

@flora-five
Copy link
Contributor

When working on my previous PR, I didn't consider this:

  1. Terragrunt with "known values" - (TG always resolves values before calling Terraform). TG wraps values with jsonencode().

Then the code in examples/complete that simulates Terragrunt is not a good simulation because it uses values not known yet.

With known values for the Terragrunt simulation, var.records_jsonencoded enabled and a small change to local.all_records (see flora-five@c72578e), the plan is ok for Terraform versions 0.13.7 to 1.2.3. I didn't actually apply the example, just tested that the plan does not fail with the known issue.

@antonbabenko
Copy link
Member Author

@flora-five Thanks for the update. I will try to find time later tonight to try to run an example with your commit.

I will make sure to provide static values (known values) for the example for Terragrunt.

# See details: https://github.com/gruntwork-io/terragrunt/issues/1211
records = try(jsondecode(var.records_jsonencoded), var.records)
records = concat(var.records, try(jsondecode(var.records_jsonencoded), []))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flora-five THIS concat was the magic solution! Thank you very much for figuring it out!

@antonbabenko antonbabenko marked this pull request as ready for review June 19, 2022 11:24
@antonbabenko antonbabenko changed the title fix: Fixing issue 59. Attempt 20. feat: Fixed the for_each value depends on resource attributes that cannot be determined until apply Jun 19, 2022
@antonbabenko antonbabenko changed the title feat: Fixed the for_each value depends on resource attributes that cannot be determined until apply fix: Fixed the for_each value depends on resource attributes that cannot be determined until apply Jun 19, 2022
@antonbabenko antonbabenko merged commit e6fe5ba into master Jun 19, 2022
@antonbabenko antonbabenko deleted the fix-issue59-records branch June 19, 2022 11:27
antonbabenko pushed a commit that referenced this pull request Jun 19, 2022
### [2.8.1](v2.8.0...v2.8.1) (2022-06-19)

### Bug Fixes

* Fixed the for_each value depends on resource attributes that cannot be determined until apply ([#72](#72)) ([e6fe5ba](e6fe5ba))
@antonbabenko
Copy link
Member Author

This PR is included in version 2.8.1 🎉

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, 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 Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The "for_each" value depends on resource attributes that cannot be determined until apply
2 participants