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

[BUG] Cloud Shell fails to run Terraform Azure AD 2.x (using MS Graph) due to MSI error #112

Open
marcosgm opened this issue Oct 14, 2021 · 1 comment
Assignees
Labels
Area-image Changes to the base/tools image AzureAD Issues related to AzureAD in Cloud Shell bug Something isn't working Iteration-Backlog Cloud Shell team will address this in the future Status-In_review Item under consideration by the Cloud Shell team Triage-needed Triage needed by Cloud Shell team

Comments

@marcosgm
Copy link

To Reproduce

system@Azure:~/cloudshell_msgraph$ cat main.tf
provider "azuread" {
}

data "azuread_client_config" "current" {}

resource "azuread_group" "example" {
  display_name     = "example"
  owners           = [data.azuread_client_config.current.object_id]
  security_enabled = true
}
system@Azure:~/cloudshell_msgraph$ terraform init

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/azuread...
- Installing hashicorp/azuread v2.6.0...
- Installed hashicorp/azuread v2.6.0 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
system@Azure:~/cloudshell_msgraph$ terraform apply
╷
│ Error: could not configure MSI Authorizer: NewMsiConfig: could not validate MSI endpoint: received HTTP status 404
│
│   with provider["registry.terraform.io/hashicorp/azuread"],
│   on main.tf line 1, in provider "azuread":
│    1: provider "azuread" {
│
╵

Observed Behavior

│ Error: could not configure MSI Authorizer: NewMsiConfig: could not validate MSI endpoint: received HTTP status 404

Expected behavior

I'm Global Admin, and I was able to use Terraform with AzureAD 1.x modules ( using the old Active Directory Graph API). According to the TF upgrade guide, no special actions must be taken when using Azure CLI authentication https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/guides/microsoft-graph

Is this specific to Cloud Shell?

Yes.
Azure CLI from a workstation works fine
Using Cloud shell, with default credentials, doesn't work with MS Graph API it seems

@marcosgm
Copy link
Author

To disable MSI authentication you have to unset the MSI_ENDPOINT
unset MSI_ENDPOINT
That allows terraform to perform API calls to MS Graph inside cloudshell

@dsajanice dsajanice added AzureAD Issues related to AzureAD in Cloud Shell Area-image Changes to the base/tools image Triage-needed Triage needed by Cloud Shell team Status-In_review Item under consideration by the Cloud Shell team Iteration-Backlog Cloud Shell team will address this in the future labels Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-image Changes to the base/tools image AzureAD Issues related to AzureAD in Cloud Shell bug Something isn't working Iteration-Backlog Cloud Shell team will address this in the future Status-In_review Item under consideration by the Cloud Shell team Triage-needed Triage needed by Cloud Shell team
Projects
None yet
Development

No branches or pull requests

3 participants