-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
More than one matching organization found #6366
More than one matching organization found #6366
Comments
@mikemeiercb Using exact match lookup? Should we consider other use cases when users do not need exact match? |
@edwardmedia The way I interpret the documentation for how the module is used is that the given domain name in the I can also understand a scenario where a user may want to see information on all similar domains as the API returns them. Maybe a flag for |
@mikemeiercb Returning all of the fuzzy matches of the API wouldn't be a bad idea, but would require a new "array" resource such as If I am understanding correctly, all you need is for the provider to use the organization that exactly matches the given domain in the case that the API returns multiple organizations. Since that is just a bit of logic bound to an already failing use case, it shouldn't affect any other use cases. Does this sound right to you? |
Yes, I think that is the ideal fix to the current scenario, where when the API returns multiple results, perform some further logic to find the result that matches the domain name provided in the original domain parameter of the module. Since the API request body doesn't seem to allow for strict filtering from what I can find, I think the google_organization should apply that strict filtering in the edge case that the API returns more than one result. This keeps it consistent where providing a domain name to the module that matches an organization results in the information of only that organization being returned to terraform. |
Hi @mikemeiercb, If that's not possible, no worries! |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Community Note
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.Terraform Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Redacted personally identifying information:
https://gist.github.com/mikemeiercb/f659b6cc410aa3c7dfda977aae342465
Panic Output
none
Expected Behavior
Terraform should have used the list of human readable domains to retrieve the Google Customer ID using the
google_organization
module, and used that Customer ID key to apply the organization policyconstraints/iam.allowedPolicyMemberDomains
.This code was taken from the Cloud Foundation Toolkit here: https://github.com/terraform-google-modules/terraform-google-org-policy/tree/master/modules/domain_restricted_sharing
Actual Behavior
The
google_organization
module uses the organizations.search API to lookup the provided domain name and returns the matching information about that domain name, including the organization ID and the Customer ID. The org policy uses the Customer ID to set a constraint on users that are allowed to be added to IAM bindings.When the user or service account has access to more than one GCP organization with similar names, such as
dev.example.com
andexample.com
, the organizations.search performs only a fuzzy lookup and can potentially return more than one organization in the response body. This results in thegoogle_organization
module throwing an error which can be found here: https://github.com/terraform-providers/terraform-provider-google/blob/master/google/data_source_google_organization.go#L73Ideally, the provider module would perform an exact match lookup on the returned response body and explicitly match to the provided domain name, and maybe provide a warning that other similar domains were found but an exact match was used.
Steps to Reproduce
terraform init
terraform plan
Results in
Important Factoids
Authenticating as a user account that has Organization Viewer role for an organization at a root domain and an organization for a subdomain of the root domain.
References
The text was updated successfully, but these errors were encountered: