-
Notifications
You must be signed in to change notification settings - Fork 82
Make exclude_folders and exclude_projects use sets and use for_each to avoid unnecessary resource updates #32
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
Conversation
…o avoid unnecessary resource updates
391a77b
to
57626ca
Compare
Could you provide me the details why this does not pass? I don't have access |
@bharathkkb could you maybe have a look again? ^^' |
@MajorBreakfast thanks for the contribution It is failing due to a problem on our end that we are working to resolve. @morgante PTAL |
Any progress on this? The reshuffling makes it so that we get 409 errors whenever we add an exclusion to the middle of the list. That's inconvenient |
@MajorBreakfast CI problems on our end have been resolved and since tests were not passing I tried debugging- left some comments with my findings. |
Tests are green now |
@MajorBreakfast LGTM overall. nit: I assume the locals like exclude_folders_list_length are not used anymore? They are still in main.tf |
Yep. The search confirms that they‘re unused. I removed them |
@morgante can you have a look? |
@bharathkkb ping |
@morgante PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay on this.
My main concern here is that by switching to for_each
we will make it impossible to reference dynamically created folders/projects. ie it will be impossible to create a folder and apply an org policy to it in the same execution.
@morgante The old code computed the length via |
You're right, it should have the same behavior now. |
@morgante This PR might have a problem. The size of the set depends on how many unique values there are. This means the size cannot be known statically if one or more entires are only known dynamically (e.g. in case it comes from a resource attribute). This makes the value not allowed in a for_each. I haven't looked deeply into this, but it I just came across a similar scenario and wanted to mention it here. |
Yeah that's unfortunately true. I don't think there's any easy fix though. |
Currently, when adding new excluded folders or projects in to the middle of the list, Terraform shows unnecessary changes due to index shifts. With this change, this no longer happens. This makes it possible to order the exclusions alphabetically without getting unnecessary changes in the plan.