-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Allow referencing one instance of a resource from another instance of that same resource #22517
Comments
Hi @cezarsa! Terraform is working as intended here because the references are resolved between the resource "null_resource" "a" {
count = 2
}
resource "null_resource" "b" {
# Access null_resource.a in here to get the list of all instances, which you
# can then combine in whatever way makes sense.
} We asked the bot to mark this as an enhancement to represent the use-case of referencing one instance of a resource from another instance of the same resource. That is architecturally impossible right now, but having this issue representing the idea will allow others to potentially share use-cases. If you are able to share more, it would be helpful to know what real problem you were trying to solve with this, since having real examples helps us to evaluate many potential solutions to a problem. |
I came across this issue when I was searching due to a cycle error that i have. I was looking for a way to combine multiple JSON IAM documents into a single document that was the merge of all of them. The goal was to make it so that I didn't have a fixed number of policies that were hardcoded and just repeating the same thing over and over again to step through the list. My code looked something like this:
When I tried to run the above, it gives the cycle error like above and stops. |
Terraform Version
Terraform Configuration Files
Debug Output
https://gist.github.com/cezarsa/a309d2a0a7ff7b00be749598a1af4707
Expected Behavior
In the config file shown above I expected no cycle to exist. It should simply be
null_resource.vm[1]
depending onnull_resource.vm[0]
and no dependencies the other way around.Actual Behavior
Running
terraform plan
causes the error:Steps to Reproduce
terraform plan
The text was updated successfully, but these errors were encountered: