-
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_invitation: support same properties as in azuread_user #650
Comments
Hi @ppanyukov, thanks for requesting this. Whilst the Invitation object contains a User container, this is read-only and only the user's ID is returned by the API. We could potentially implement this by updating the guest user separately after the invitation is created, but I'd first like to experiment and see if this can be done with the existing user resource, and also investigate to see which properties are updateable for guest users yet to accept their invitation. |
Hmm, I really hoped this wouldn't be the case but oh well... Would it be breaking "tf resource best practice" if we do two operations (create and then update) on a single resource? Say create succeeds but update fails for some reason (network issue), what happens with the tf state? Tainted? Although Another alternative is to have separate resource say Of course having all these just in Judging from the Azure Portal, we can edit all the same properties for invited users as for the regular ones. I don't know if this helps? |
Performing multiple operations for a single logical operation in Terraform is fine, as you say we do this in lots of places. If the create operation gets far enough to assign a resource ID, then it is in fact tainted on failure. |
Oh, while we are at it, this makes me very sad :(
|
There's no way to read back invitations as it's a POST only endpoint - however you can import guest users into an |
What we struggle with not having any way to set the First and Last names for the created object, this is an issue with things like AAD SCIM sync to sync the guests to other 3rd party apps, (AWS SSO for example) that require First and Last name attributes. I understand this is likely limitation on the azure api but still my 2 cents |
Seems like it should be possible to support the attributes in the Azure Portal when inviting a New User. Looking at the code there is an update of the newly created user that takes place following the actual invitation so this could support updating attributes like the First Name and Last Name, etc. (I guess at least should be able to set the First Name, Last Name, Job Title, Department, Company name and possibly Usage location). The resource is already reading the Email from the existing user in the Proposed changes:
I don't mind looking at making the changes and creating pull request, that is if the suggested changes are appropriate! This would at least provide the same level of functionality as the Invite user form in Azure AD (excluding Groups, Roles and Manager) |
I'm unsure why you need this as the locals {
invited_folks = yamldecode(file("${path.module}/../invited_folks.yml"))
}
resource "azuread_invitation" "invite" {
for_each = local.invited_folks
user_email_address = each.key
redirect_url = "https://example.com"
message {
additional_recipients = [each.value.inviter]
body = <<-EOT
Hello ${each.key}
You have been invited to example.com
Please accept this invite to get access.
Have a nice day!
EOT
}
}
resource "azuread_group_member" "example" {
group_object_id = "<an object id>"
for_each = local.invited_folks
member_object_id = azuread_invitation.invite[each.key].user_id
}
with a ---
[email protected]:
inviter: [email protected]
[email protected]:
inviter: [email protected] |
We intend to approach this by incorporating invite functionality into the |
Any updates on this? This is quite and urgent requirement for out needs as we manage ALL our users through terraform using the azuread_invitation resource and we are currently unable to set any of the additional attributes |
This pull request was completed in record time. Thank you so much. However, it turned out to be a foot gun when I got it in my hands. You see, just like the user in #851, I too was inviting users that didn't exist in my Azure Tenant. When I used For users that were not found I was using I wanted to provide my feedback as a warning to others who also run into issues like #851. I hope they can be addressed with whatever is happening in this request. In the meantime, we have determined that user invitations into the tenant will be a manual process until the sharp edges can be removed and confidence can be regained in the |
@Gonkers Sorry to hear about your outage, but thanks for reporting back - context like this is very useful in shaping design choices around rough primitives like B2B invitations. We can try to add some guardrails here. In your case, did you have multiple invitations corresponding to one external user, and/or an invitation(s) that went unanswered but the resulting user was already present and active in your tenant? |
There are 2 tenants, one for the entire company and a second for Azure resources and those who work on those Azure resources. All users in the Azure tenant are guests, but their email addresses are not necessarily consistent with the primary tenant. This meant some of the emails that I was using to look them up were not associated with their guest account. They still got the invitations and signed in with their guest account. That last part is what associated the invitation to their guest account. So when I thought we wouldn't need the invitations and removed them, it deleted the user accounts. |
Community Note
Description
The
azuread_user
resource supports many properties likedepartment
,company
etc, and most notablyaccount_enabled
-- pretty much all fields I can set manually in AAD.The
azuread_invitation
doesn't have any of these at all. And again most notably it doesn't haveaccount_enabled
. At the same time, we can edit and populate all these fields manually in AAD.We use many external users in our AAD and we use the metadata extensively to document their roles and why they are in our AAD at all.
The proposal is to "beef up"
azuread_invitation
to support all the same properties asazuread_user
(except there is no need for password of course).Looking at the graph SDK, the
Invitation
struct does have the*User
member, and it is the same type being used byazuread_user
, so in theory this should be just a matter of exposing the properties and fill out this object inazuread_invitation
?Of course if this is possible and is implemented, then we'd want
azuread_invitation
to return extra attributes too.The text was updated successfully, but these errors were encountered: