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 here to configure terraform to use a managed-identity
.
However whenever I run terraform apply/plan
etc I see the following error:
│ Error: Unable to list provider registration status, it is possible that this is due to invalid credentials or the service principal does not have permission to use the Resource Manager API, Azure error: resources.ProvidersClient#List: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="SubscriptionNotFound" Message="The subscription 'xxxxxxxxx-xxxx-xxxxx-xxxxx-xxxxxxxxxxx' could not be found."
(xxxxxxxxx-xxxx-xxxxx-xxxxx-xxxxxxxxxxx is me redacting the subscription-id)
Below is a snippet of my configuration and my workflow/process for bootstrapping:
- Create a Virtual Machine with a managed identity, assign it the
Owner
role (just for testing purposes) - Run
az cloud set -n AzureUSGovernment
- Run
az login --identity
- Run the terraform code.
Other Important Things to Note:
- The exact same configuration/process works just fine in Azure Commercial.
- Running
az
commands from the VM works just fine (I have RBAC permissions to do things in the account) - Here is my
provider.tf
:
provider "azurerm" {
features {}
use_msi = true
subscription_id = "MYSUB-ID"
tenant_id = "MYTENANT-ID"
}
Any help is super appreciated! Thanks!