-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Data source reference for_each resource is 1 timestep old #24948
Comments
@yorinasub17 I believe the issue you're running into is that data sources are currently all pulled at the very beginning of the terraform apply. In the upcoming Terraform 0.13 release, @jbardin is refactoring this so that data sources are part of the graph and participate in dependency ordering. @jbardin does this look like it'll be within scope of the refactor you're doing? If so, I think we can close this with the expectation it'll be fixed in 0.13. |
Yes, this is something that we're working on implementing for 0.13. We can close this however as a duplicate of #17034, which will be closed when the corresponding changes can be merged. |
Thanks for the information! Will subscribe to the other issue, and wait patiently for FWIW, I found a workaround by injecting a |
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. |
Terraform Version
Terraform Configuration Files
Expected Behavior
All modifications to
aws_s3_bucket.test
that cause changes to the policy document are handled in a single timestep when runningapply
.Actual Behavior
Any changes that cause at least one of the resources in the
for_each
call to be removed or modified do not translate to a change of the iam policy. Here is the plan I see after removing one of the names in the list (in this case I am removingbar
):Note how this only updates the s3 bucket, but the data source isn't recomputed after the change happens, leaving the IAM role policy to be stale. The change is only propagated to the data source after running
apply
; when I runplan
after applying this change, I see the data source being updated and subsequently the IAM role policy. Here is the plan from the secondapply
immediately after applying the above plan:This doesn't appear to happen if the change is to add a new
for_each
resource. E.g., if you add back inbar
after this the first plan includes updates to both the IAM role policy and the s3 bucket.Steps to Reproduce
terraform init
terraform apply
var.names
list.terraform plan
<= This should include updates to bothaws_s3_bucket.test
andaws_iam_role_policy.read_s3
.The text was updated successfully, but these errors were encountered: