-
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
provider/google: ignore expanded v collapsed policies in diff #12387
Conversation
When comparing the config and state for google_project_iam_policy, always merge the bindings down to a common representation, to avoid a perpetual diff. Fixes #11763.
} | ||
} | ||
|
||
func testAccCheckGoogleProjectIamPolicyIsMerged(projectRes, policyRes, pid string) resource.TestCheckFunc { |
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.
A lot of the error checking in this function is duplicated from testAccCheckGoogleProjectIamPolicyExists
, which is called from this fn. I wouldn't mind seeing something like (either or some combination of):
- The error-checking is removed from this function since calling the other one takes care of it
- A helper function could take care of getting the
projectP
andpolicyP
values (and doing the error-checking) that gets called from both functions
data "google_iam_policy" "expanded" { | ||
binding { | ||
role = "roles/viewer" | ||
members = [ |
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.
nit: indentation (make this spaces instead of tabs)
|
||
binding { | ||
role = "roles/viewer" | ||
members = [ |
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.
and here
Refactored some helpers out that help with retrieving the policies from state and comparing them, hopefully leading to less code duplication.
Tabs vs spaces is the worst. I really need a way to run terraform fmt on these inline configs.
Comments should be addressed. :) |
Looks good, thanks! |
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 comparing the config and state for google_project_iam_policy,
always merge the bindings down to a common representation, to avoid a
perpetual diff.
Fixes #11763.
I also added a test to ensure the fix worked. Output of the test without the fix in place:
Output after fix: