Skip to content
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

Failure to retreive obecjts (users and groups) with MSI authentication #347

Closed
gitmaximd opened this issue Oct 29, 2020 · 4 comments · Fixed by #350
Closed

Failure to retreive obecjts (users and groups) with MSI authentication #347

gitmaximd opened this issue Oct 29, 2020 · 4 comments · Fixed by #350

Comments

@gitmaximd
Copy link

gitmaximd commented Oct 29, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritise this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritise the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureAD Provider) Version

Terraform v0.12.29

  • provider.azuread v1.0.0

Affected Resource(s)

  • azuread_group
  • azuread_user

Terraform Configuration Files

provider "azuread" {
  use_msi = true
}

data "azuread_group" "aks_rbac" {
  name = "AKSAdmins"
}

data "azuread_user" "example" {
  user_principal_name = "[email protected]"
}

output "oid" {
  value = data.azuread_user.example.object_id
}

output "id" {
  value = data.azuread_group.aks_rbac.id
}

Debug Output

https://gist.githubusercontent.com/gitmaximd/dff9087b41dd82b0c6c60c18f2880481/raw/25adc49c57825023efe1e7007c8a47292d5c4260/gistfile1.txt

Panic Output

Expected Behavior

Successfully retrieve user or group object information

Actual Behavior

While using MSI for authentication the data resource fails to retrieve the information. Same code works with SP authentication.

Steps to Reproduce

  1. terraform apply

Important Factoids

I noticed that the request URL is incorrectly constructed and is missing Tenant domain name. For example:
https://graph.windows.net//groups?%24filter=displayName+eq+%27AKSAdmins%27&api-version=1.6
It should be like this one: https://graph.windows.net/domain.com/groups?%24filter=displayName+eq+%27AKSAdmins%27&api-version=1.6

References

  • #0000
@manicminer
Copy link
Contributor

manicminer commented Nov 13, 2020

Hi @gitmaximd, thanks for raising this issue! When using MSI authentication, you do also need to specify the tenant ID, either using the tenant_id argument in the provider block, or via the ARM_TENANT_ID environment variable. It's not possible for us to auto-determine the tenant from the MSI endpoint response.

Our documentation could be clearer about this, so I'm going to mark this issue as a documentation bug so that we can address this and make it clearer how you should configure the provider. We can also improve our validation so the provider doesn't attempt to proceed with an incomplete configuration.

@manicminer
Copy link
Contributor

We have added clarification to our documentation for authentication using a managed identity, that a tenant ID is always required. I believe this will resolve this issue, and so I'm going to close it for now. Please comment further if you continue to see this error after adding a tenant ID to your configuration and we'll be happy to reopen. Thanks!

@ghost
Copy link

ghost commented Nov 25, 2020

This has been released in version 1.1.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azuread" {
    version = "~> 1.1.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Dec 19, 2020

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!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants