Failed to query available provider packages - azure

I'm using the Powershell in the Azure Portal.
Terraform version = v1.0.3
Powershell version = 7.1.3
this is my code
provider "azurerm" {
features {}
}
resource "azure_storage_account" "lab" {
name = "newbloddystoragegroup"
resource_group_name = "TFResourcegroup"
location = "eastus"
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azure_storage_container" "lab" {
name = "blobcontainer4dev"
storage_account_name = azure.storage.account.lab.name
container_access_type = "private"
}
resource "azure_storage_blob" "lab" {
name = "TerraformdevBlob"
storage_account_name = azure_storage_account.lab.name
storage_container_name = azure_storage_container.lab.name
account_replication_type = "Block"
}
resource "azure_storage_share" "lab"{
name = "terraformdevshare"
storage_account_name = azure_storage_account.lab.name
quota = 50
}
but when I run terraform init..I get the following error
Initializing provider plugins...
- Finding latest version of hashicorp/azurerm...
- Finding latest version of hashicorp/azure...
- Installing hashicorp/azurerm v2.74.0...
- Installed hashicorp/azurerm v2.74.0 (signed by HashiCorp)
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/azure: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/azure
│
│ Did you intend to use terraform-providers/azure? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on hashicorp/azure, run the following command:
│ terraform providers
I've run this..
terraform providers
Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/azure]
└── provider[registry.terraform.io/hashicorp/azurerm]
but I don't know what I have to change
What I've tried ...
I've put
provider "azurerm" {
features {}
}
into its own provider.tf file...but I'm still getting the error
I've tried to put
provider "registry.terraform.io/hashicorp/azurerm" {
features {}
}
...but it turns out that that is unacceptable syntax
I've tried replacing
provider "azurerm" {
features {}
}
with
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "2.74.0"
}
..but that didn't work either
..any help is gratefully received....just guide me ..you don't necessarily need to tell me the answer

I believe you have gotten this error because you used azure_* resources
If you open Azure Provider documentation you will figure out that all resources names start with azurerm_* prefix.

Related

Terraform init failed. Error: Failed to query available provider packages

Installed terraform & init is failing.
- Finding hashicorp/aws versions matching "~> 4.16"...
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/aws: could not connect to registry.terraform.io: Failed to request discovery document: Get
│ "https://registry.terraform.io/.well-known/terraform.json": x509: “cf-registry.tf-registry-prod-use1.terraform.io” certificate is not standards compliant
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.2.0"
}
provider "aws" {
region = "us-west-2"
}
resource "aws_instance" "app_server" {
ami = "ami-830c94e3"
instance_type = "t2.micro"
tags = {
Name = "ExampleAppServerInstance"
}
}
I have uninstalled and reinstalled it but still not working.
Terraform version: Terraform v1.3.7 on darwin_amd64
I was facing the same issue, even with a module that was working well previously. After discarding network issues ( curl https://registry.terraform.io/.well-known/terraform.json ), trying with different files and directories, etc. It turned out that a reboot did the trick for me.

terraform azure insufficient blocks

Here is my terraform plan
terraform {
required_providers {
azure = {
source = "hashicorp/azurerm"
version = "=3.5.0"
}
}
backend "s3" {
encrypt = true
bucket = "terraform"
region = "us-east-1"
key = "aws/tgw_peer/us-east-1/terraform.tfstate"
}
}
provider "azurerm" {
features {}
}
data "azurerm_virtual_network" "vnet" {
resource_group_name = var.resource_group_name
name = var.vnet_name
}
When I execute terraform plan I get the following error:
╷
│ Error: Insufficient features blocks
│
│ on <empty> line 0:
│ (source code not available)
│
│ At least 1 "features" blocks are required.
╵
There is clearly a features block in the azurerm provider block. However, the fact that the error doesn't specify the file name tells me that maybe the problem is somewhere else.
What am I doing wrong?
Terraform version 1.1.6
The name of the provider in the required_providers block is wrong, you have set it to azure while it should be azurerm. Example of how to configure the provider:
terraform {
required_providers {
azurerm = { # <--- Note that it is azurerm
source = "hashicorp/azurerm"
version = "3.5.0"
}
}
}
provider "azurerm" {
# Configuration options
}

AKS Cluster | Failed to query available provider packages | Right version of hashicorp

I'm currently building my terraform plan and it seems that I'm running into issues as soon as I run the following command:
terraform init
The current main.tf contains this:
terraform {
backend "azurerm"{
resource_group_name = "test"
storage_account_name = "testaccount"
container_name = "testc"
key = "testc.state"
}
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "2.46.0"
}
}
}
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
}
data "azurerm_key_vault" "keyVaultClientID" {
name = "AKSClientID"
key = var.keyvaultID
}
data "azure_key_vault_secret" "keyVaultClientSecret" {
name = "AKSClientSecret"
key_vault_id = var.keyvaultID
}
resource "azurerm_kubernetes_cluster" "test_cluster" {
name = var.name
location = var.location
resource_group_name = var.resourceGroup
dns_prefix = ""
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v2"
}
service_principal {
client_id = data.azurerm_key_vault_secret.keyVaultClientID.value
client_secret = data.azurerm_key_vault_secret.keyVaultClientSecret.value
}
tags = {
"Environment" = "Development"
}
}
The error message that I get is the following:
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/azure: provider
│ registry registry.terraform.io does not have a provider named
│ registry.terraform.io/hashicorp/azure
I'm looking at the documentation, and I'm changing the version, but I'm not getting any luck. Does anyone knows what else I can do or what should I change on my main.tf?
The solve this issue, you will have to add the following inside of the main terraform plan:
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.75.0"
}
If you add it, the issue will never appear again. Also, you might have to run the upgrade command to make sure terraform will be able to handle the new version.

Terraform plan throws Provider Plugin Error

I am doing a small POC with terraform and I am unable to run terraform plan
My code:
terraform {
backend "azurerm" {
storage_account_name = "appngqastorage"
container_name = "terraform"
key = "qa.terraform.tfstate"
access_key = "my access key here"
}
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.77"
}
}
}
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "qa_resource_group" {
location = "East US"
name = "namehere"
}
My execution:
terraform init = success
terraform validate = configuration is valid
terraform plan = throws exception
Error:
│ Error: Plugin error
│
│ with provider["registry.terraform.io/hashicorp/azurerm"],
│ on main.tf line 15, in provider "azurerm":
│ 15: provider"azurerm"{
│
│ The plugin returned an unexpected error from plugin.(*GRPCProvider).ConfigureProvider: rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8
After digging a little deeper I was able to figure out what was the issue.
Current project I am working on is been utilized within multiple regions. So, when testing work I am swapping my region in order to properly test the data that displays in specific region. This time when running terraform apply my windows configuration was pointing to another region not the US.
This thread helped me understand.
Upgrade azure CLI to the latest version using az upgrade
Log into your azure account using az login
Re-run your terraform commands!

Terraform try to pull not defined provider

Every time I perfomr terraform init tf try to pull from registry quite strange provider which do not exit.
Error:
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/databricks: provider registry registry.terraform.io does not have a provider named
│ registry.terraform.io/hashicorp/databricks
│
│ Did you intend to use databrickslabs/databricks? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on
│ hashicorp/databricks, run the following command:
│ terraform providers
╵
This providere is quite strange combination of 2 providers.
My tf file:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 2.65"
}
databrick = {
source = "databrickslabs/databricks"
version = "0.3.7"
}
}
required_version = ">= 0.14.9"
}
provider "azurerm" {
features {}
}
provider "databrick" {
features {}
}
resource "azurerm_resource_group" "rg" {
name = "TerraformResourceGroup"
location = "westeurope"
}
resource "azurerm_databricks_workspace" "databrick" {
name = "terraform-databrick"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
sku = "trial"
tags = {
"env" = "rnd"
"provisoning" = "tf"
}
}
data "databricks_node_type" "smallest" {
local_disk = true
}
data "databricks_spark_version" "latest_lts" {
long_term_support = true
}
resource "databricks_cluster" "cluster" {
cluster_name = "terraform-cluster"
spark_version = data.databricks_spark_version.latest_lts.id
node_type_id = data.databricks_node_type.smallest.id
autotermination_minutes = 20
spark_conf = {
"spark.databricks.cluster.profile" : "singleNode"
"spark.master" : "local[*]"
}
custom_tags = {
"type" = "SingleNode"
"env" = "rnd"
"provisoning" = "tf"
}
}
I was looking for some kind of 'verbose' flag, so I could find why it is trying to pull this kind of provider and from where it is coming.
Sadly I was able only to be able to find up that this issue is comming from 'data' and below part of my file.
All my knowlage is based on this docs Data brick cluster and this learning material Terraform Azure
Thank you in advace all of your help.

Resources