Home > Mobile >  Azure Managed Identity and Terraform not working in AzureUSGoverment
Azure Managed Identity and Terraform not working in AzureUSGoverment

Time:09-29

I am trying to use a managed-identity to authenticate to Azure and run terraform from a virtual machine in the AzureUSGovernment cloud. I've followed the guide found enter image description here

Note: This is because the the subscription I am using is not on Azure Government cloud instead its in Azure Cloud. Please make sure you are using the correct subscription for which you have created the managed identity and the ensure the environment its in.

And , After you checked the subscription and environment , you can skip these steps :

Run az cloud set -n AzureUSGovernment
Run az login --identity

Instead you can directly use the the terraform code:

provider "azurerm" {
  features {}
  use_msi = true
  subscription_id = "948d4068-xxxx-xxxxxx-xxxxxxx-xxxxxxxx"
  tenant_id = "72f988bf-xxxx-xxxxx-xxxxxx-xxxxxxxxx"
  environment = "usgovernment"
}

resource "azurerm_resource_group" "test" {
    name="xterraformtest12345"
    location ="east us"
}

Note:

If your subscription is in public then there is no need to set the environment and if its in some other then you can set the environment as required.

Output: After removing the environment as the subscription is in public cloud

enter image description here

  • Related