-
Notifications
You must be signed in to change notification settings - Fork 301
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
azuread_group is broken in v1.6.0 with use_microsoft_graph = true #478
Comments
I have the feeling (sorry, cannot say for sure) that it worked a couple of days ago with the same version. Maybe Microsoft changed (broke) something?! As a workaround, I am now using an alternate provider config (via
Hope this helps at least until the fix arrives. |
Oh, this seems to be related to or even a duplicate of #464 although I do not see how this is related to the owners:
|
Hi @ibacalu, thanks for reporting this. There is at least one known recent upstream issue with groups management (see #464 and #473), however before concluding this is the same issue, I'm trying to reproduce the error you are seeing. I'm starting with the assumption that the owners or members are the likely cause. If you could check the following it will be helpful:
|
Ha you beat me to a reply! That's helpful thanks, it may be that the provider is attaching the calling principal twice, if it's also specified in the configuration. |
@ibacalu Could you try the same configuration, but ensuring that the calling principal is not included in the list of owners and/or members (narrowing it down to the correct property will also help). Thanks! |
Hi guys. Thanks for looking into this! @manicminer I was trying to create this group with one principal and with a different principal in the owners. No Owners:Terraform will perform the following actions:
# azuread_group.this will be created
+ resource "azuread_group" "this" {
+ description = "Test azuread_group Module"
+ display_name = "azuread_group-test"
+ id = (known after apply)
+ mail_enabled = (known after apply)
+ members = (known after apply)
+ name = (known after apply)
+ object_id = (known after apply)
+ owners = (known after apply)
+ prevent_duplicate_names = false
+ security_enabled = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ config = {
+ description = "Test azuread_group Module"
+ display_name = "azuread_group-test"
+ members = []
+ owners = []
+ prevent_duplicate_names = null
}
+ this = (sensitive value)
azuread_group.this: Creating...
│ Error: Creating group "azuread_group-test"
│
│ with azuread_group.this,
│ on main.tf line 11, in resource "azuread_group" "this":
│ 11: resource "azuread_group" "this" {
│
│ GroupsClient.BaseClient.Post(): unexpected status 400 with OData error:
│ Request_BadRequest: Request contains a property with duplicate values. Different ownerTerraform will perform the following actions:
# azuread_group.this will be created
+ resource "azuread_group" "this" {
+ description = "Test azuread_group Module"
+ display_name = "azuread_group-test"
+ id = (known after apply)
+ mail_enabled = (known after apply)
+ members = (known after apply)
+ name = (known after apply)
+ object_id = (known after apply)
+ owners = [
+ "********-****-****-****-********fc56",
]
+ prevent_duplicate_names = false
+ security_enabled = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
Changes to Outputs:
~ config = {
~ owners = [
+ "********-****-****-****-********fc56",
]
# (4 unchanged elements hidden)
}
+ this = (sensitive value)
azuread_group.this: Creating...
╷
│ Error: Creating group "azuread_group-test"
│
│ with azuread_group.this,
│ on main.tf line 11, in resource "azuread_group" "this":
│ 11: resource "azuread_group" "this" {
│
│ GroupsClient.BaseClient.Post(): unexpected status 400 with OData error:
│ Request_BadRequest: Request contains a property with duplicate values. ➜ az account show
{
"environmentName": "AzureCloud",
"id": "********-****-****-****-********6d29",
"isDefault": true,
"name": "N/A(tenant level account)",
"state": "Enabled",
"tenantId": "********-****-****-****-********6d29",
"user": {
"name": "*@*.com",
"type": "user"
}
} The error is the same in Azure Portal:
|
@manicminer Thx for your quick reply! I tried all combinations I could come up with:
All fail when using Microsoft Graph API and succeed otherwise. |
I have no access to our AAD's audit log to look for error messages there. |
Thanks for the info, that's super helpful. In the combination testing you did, was the other principal a service principal or a user? When you say the error is the same in the portal, do you mean you're unable to create a group in the portal too, or that you're seeing the error logged there? |
Also, just to note that I have not yet been able to reproduce the error you're getting. It might be that the tenant you're using has different semantics, possibly due to location, generation or SKU. |
Oh, that sounds bad for us. ;-) Unfortunately, I am not an admin for our AD. I can only see the following info: License: Azure AD Premium P2 I am using my personal user (not SP) authenticated via Azure CLI for running Terraform. I can create groups via the Azure Portal. I will try with a SP instead later (but this requires some "work" as I need an admin's consent for the SP's API permissions). |
Thanks again, I'll continue trying to repro whilst authenticating as some user principals via Azure CLI |
I was trying to see anything helpful in the TRACE logs but I could not spot the requests which are sent to MS Graph API. Did I just miss it or is there any way I can help by providing logs? |
The MS Graph requests are unfortunately not yet included in the debug log, this will be fixed in v2.0. Do you have a MITM proxy you could run to grab the failed request(s)? Something like Proxyman or Charles? |
I meant the error I see in the portal is the same if i try to create it with the same principal or with a different principal in the owners (both through terraform). provider "azuread" {
use_microsoft_graph = false
} My tenant is also in Germany, so that could be something...
|
That's useful context, thanks @ibacalu 👍 We're still following up with the service team to get to the bottom of this and/or create a workaround. For anyone affected by this, can you confirm which permissions you have effectively granted Terraform when accessing MS Graph, i.e. API roles such as |
@manicminer I was running into the exact same issue as @ibacalu using a User Principal with the exact same error in the audit logs and enabling the Groups Administrator role resolved the issue for me. @ibacalu this may resolve your issue as well. It appears that the error message:
Is a generic response. I did notice that if I updated existing resources I did not need the Groups Administrator role assigned to my User though. And I also got a different error when attempting to set a Group as an Owner on a Group (This isn't allowed in the Portal either). |
Thanks @cparkins! Do you know which other roles/permissions you had assigned before granting Groups Admin? |
@manicminer I had no Azure AD Roles previously but do have the owner role at the Subscription level. |
I do not get the point of the whole roles & permissions stuff because I do not have any problems via the Azure Portal or via the Azure CLI:
As I am using Azure CLI as authentication mechanism for the Terraform provider, the issue seems to be unrelated to my role & permissions. Basically, the provider should execute "the same" request as via |
Hi @ju-la-berger, unfortunately there's a bit more complexity involved. In your Terraform config you can specify any number of owners, which not only have to be applied in the same operation, but unlike a fire-and-forget CLI command, Terraform needs to ensure that it can continue to manage and update a group after it has been created and the owners manipulated per a user's configuration. Unlike Azure CLI, which is a first party MS application and has special privileges that Terraform can never have, Terraform has to cater for a range of auth scenarios including accessing the API on behalf of a user (acquiring a token via az-cli), or as a service principal, and each of these have their own considerations in terms of how the API determines your permissions. The root of this issue appears likely to be a service change which, if we work around, forces us to break users with certain auth setups, which is why I'm trying to gather more information from affected users. Note that when you run I'm going to guess that maybe you don't have any directory roles granted to your "[email protected]" user? If that's the case, any workaround we put in place would preclude you from using Terraform to manage your groups without acquiring an administrative role, which is something we'd like to avoid if at all possible. |
Found another related issue. │ Error: Deleting group with object ID: "********-****-****-****-********1350"
│
│ graphrbac.GroupsClient#Delete: Failure responding to request:
│ StatusCode=403 -- Original Error: autorest/azure: Service returned an
│ error. Status=403 Code="Unknown" Message="Unknown service error"
│ Details=[{"odata.error":{"code":"Authorization_RequestDenied","date":"2021-07-16T08:27:08","message":{"lang":"en","value":"Insufficient
│ privileges to complete the
│ operation."},"requestId":"********-****-****-****-********12b5"}}] |
@ibacalu Thanks for reporting. I think I'd probably consider that a separate issue, and it looks like you're not using MS Graph there? Could you open a new issue for that? Thanks! |
@manicminer Sorry for the late reply. It's holiday season. Regarding your question: My user "[email protected]" has elevated rights ("Directory Reader" and "Application Developer"). I can enable these roles via Azure PIM. Does not make any difference regarding this issue though. Thanks for your explanations regarding the app-specific rights. I am just beginning to explore this whole topic. Maybe we can track this issue down once we have more logging in place (what is actually sent to the Graph API including the token). However, I am pretty sure (99%; based on my Git commit logs) that group creation worked the week before. So, something in our tenant has changed which is causing this issue. I can even imagine that maybe our AD admins (accidentally) blocked us somehow. |
Additional fixes to follow |
Draft fixes for the identified issues above are in #519 Anyone with knowledge of the codebase and/or Go who has experienced any of the above, is welcome to review |
@ibacalu, @ju-la-berger, @patrickmarabeas, @huwjeffries - thanks all for reporting these groups bugs and helping to narrow down the root causes. We've worked with the service team to try and get some more insight, and have implemented better logic around group ownership on which I'm hoping to get your feedback whether this helps in your respective cases. I've published a test build to the TF Registry which you can consume with the following provider config: terraform {
required_providers {
azuread = {
source = "manicminer/azuread"
version = "11.0.6"
}
}
} This is effectively a 2.0 RC build despite the nonsense version number I used. For a brief breakdown of most of the behavioral changes see #519. Any feedback will be gratefully received and will help us move closer to the next release. Thanks! Ed: build number bumped to 11.0.6 |
"Swapping" owners now works as expected, i.e. adding and removing a single own at the same time works. Service principals are still not respected as being a valid single group owner, however. The following is the error when a user and a service principal have both been applied as a group's owners, and then the user is subsequently removed leaving only the service principal.
I'm not sure if this is a big deal, but it is odd. Anpother oddity -
Returns error However, removing Owner shouldn't be enforced, as the API does allow for groups with no owners, however, once there are assigned owners there MUST, from that point on, be an owner. This really needs to be picked up by the plan, as well. |
@patrickmarabeas Thanks for testing! That is super helpful feedback and although you have still encountered some errors, that is actually the expected behavior end-to-end at this point.
Great!
This is unfortunately an API behavior/bug and we have no choice but to document this and live with it.
Actually it's not possible to create a group with no owners. The API always assigns the caller as the owner, effectively stamping permanent ownership on the group, since as you note owners can never be totally removed. When you omit Removing the |
Ahh, understood. Thanks! |
This functionality has been released in v2.0.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I still get this error in 2.1.0:
I created a group
and I get this error still. I tried with owners and depending on owners I get either the same error or some other one. What is weird that I have 2 modules and both have this group and it works in one case, but not the other! (names are different). So I am completely lost as to what is going on P.S. I have tried later and it just started working... |
Sounds great, thanks for the update! |
i still have the same error with v2.2.0 . this worked with 1.2.2 it looks like the error is occuring only when i include the current user as owner. If i put another user it works like expected. maybe is the current user(creator) added by default and conflicts with the owners block if the owners block also contains the current user? |
H @iulianmarius, thanks for reporting. Please could you post a reproducible config in full, and a debug log? In all our test configurations this is no longer occurring, it seems likely that something about your configuration may be triggering this incorrect behavior. Thanks! |
Hi I'm also getting the "GroupsClient.BaseClient.Post(): unexpected status 400 with OData error:" error. I've managed to isolate some cases where it happens and where it doesn't, hope it's helpful. Setup:
Errors out:
Succeeds:
At this point I'd guess it's some weird issue within Azure itself; for the time being setting group_admin as default owner solves it for us (although it might not fit everybody's use case). |
Thanks @nfeltrin-dkb, there are ongoing known service issues with group ownership and I agree what you've documented looks like an API bug. At this time, we're fairly confident that the provider is doing the right thing with regards to group ownership and the following (misleading) errors, are very likely to be caused by known API bugs:
|
Thanks again to all who helped debug this issue, your help is greatly appreciated. Since it seems that what remains of this issue is due to an API bug, I've reported this upstream at microsoftgraph/msgraph-metadata#92 and will be closing this issue for now. If you're still experiencing this issue, I encourage you to report your observations on the upstream issue to give the service team the best possible set of evidence. Thanks! |
Community Note
Terraform (and AzureAD Provider) Version
Affected Resource(s)
azuread_group
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
New group created in AzureAD
Actual Behavior
Nothing gets created and error is thrown.
Azure Log:
Steps to Reproduce
terraform apply
Important Factoids
Setting
use_microsoft_graph = false
creates the group without any issues.References
The text was updated successfully, but these errors were encountered: