when ever i terraform init, i get this
Initializing the backend...
container_name
The container name.
Enter a value:
I have tried creating a new cluster following Microsoft guide here https://learn.microsoft.com/en-us/azure/aks/learn/quick-kubernetes-deploy-terraform?tabs=azure-cli and it also didnt work. here is the error below
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/azurerm versions matching "~> 3.0"...
- Finding hashicorp/random versions matching "~> 3.0"...
- Finding hashicorp/time versions matching "0.9.1"...
- Finding azure/azapi versions matching "~> 1.5"...
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/azurerm: could not connect to registry.terraform.io: failed to request discovery document: Get
│ "https://registry.terraform.io/.well-known/terraform.json": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
╵
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/random: could not connect to registry.terraform.io: failed to request discovery document: Get
│ "https://registry.terraform.io/.well-known/terraform.json": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
╵
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/time: could not connect to registry.terraform.io: failed to request discovery document: Get
│ "https://registry.terraform.io/.well-known/terraform.json": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
╵
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider azure/azapi: could not connect to registry.terraform.io: failed to request discovery document: Get
│ "https://registry.terraform.io/.well-known/terraform.json": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2
Answers
for me, the solution was to leave my company network and use my home wifi.
The errors you’re facing suggest that Terraform is unable to establish a connection with the provider registry (registry.terraform.io). This issue might be arising because you attempted to store the backend configuration file after logging into Azure (
Az
) using aService Principal
, yet the problem persists.To address this problem, you must furnish the
client_id
,client_secret
,subscription_id
, andtenant_id
associated with the service principal within thebackend
section of your Terraform configuration. This step is crucial for resolving the issue and enabling proper communication between Terraform and the Azure provider registry.My terraform configuration:
Provider.tf
ssh.tf
main.tf
variable.tf
output.tf
Output:
Commad
Terraform init
Command
Terraform apply