While running the steps at Build Infrastructure - Terraform Azure Example | Terraform | HashiCorp Developer to create a resource group in Azure, terraform plan freezes. Only when hitting Ctrl+C to cancel, the following error is prompted:
user@machine:~/learn-terraform-azure$ terraform plan
^C
Interrupt received.
Please wait for Terraform to exit or data loss may occur.
Gracefully shutting down...
Stopping operation...
Planning failed. Terraform encountered an error while generating this plan.
│ 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 sending request: StatusCode=0 -- Original Error: context canceled
│ with provider["registry.terraform.io/hashicorp/azurerm"],
│ on main.tf line 13, in provider "azurerm":
│ 13: provider "azurerm" {
│
The main.tf file has been set as follows:
# Configure the Azure provider
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0.2"
}
}
required_version = ">= 1.1.0"
}
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "rg" {
name = "myTFResourceGroup"
location = "australiaeast"
}
Service principal has been created.
az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/<SUBSCRIPTION_ID>"
and environmental variables have been set
user@machine:~/learn-terraform-azure$ set | grep ARM
ARM_CLIENT_ID=<some id>
ARM_CLIENT_SECRET=<some password>
ARM_SUBSCRIPTION_ID=<subscription id>
ARM_TENANT_ID=<tenant id>
Not sure if relevant, but I am runnning terraform on Ubuntu.
user@machine:~/learn-terraform-azure$ terraform --version
Terraform v1.4.3
on linux_amd64
+ provider registry.terraform.io/hashicorp/azurerm v3.0.2
What could be causing the issue?