While trying to create EventHub Authorization Rule, getting the below error message. Not able to really get through this.
TF Code:
resource "azurerm_eventhub_authorization_rule" "jdBulkMessenger" {
name = "jd-bulk-messenger"
namespace_name = azurerm_eventhub_namespace.eventhub_ns.name
eventhub_name = azurerm_eventhub.eventhub.name
resource_group_name = data.azurerm_resource_group.rg.name
listen = true
send = false
manage = false
}
Tried with Different Provider Version but the same issue persists:
terraform {
required_providers {
azurerm = {
version = "~> 2.29.0"
}
}
}
Error:
Error: Error making Read request on Azure EventHub Authorization Rule : eventhub.EventHubsClient#GetAuthorizationRule: Invalid input: autorest/validation: validation failed: parameter=authorizationRuleName constraint=MinLength value="" details: value length must be greater than or equal to 1
I tried to reproduce the same :
Even I had similar error Error: Error making Read request on Azure EventHub Authorization Rule: parameter=authorizationRuleName constraint=MinLength value="" details: value length must be greater than or equal to 1 when I had older arurerm provider version 2.15.0
Providers.tf
azurerm = {
source = "hashicorp/azurerm"
version = "2.15.0"
}
Then I changed the azurerm provider version to 3.0.2 and it worked .
Check if both AzureRM Provider and Terraform Core versions are old
and upgrade to the latest versions as it may be fixed in latest
versions.
Also check if that azurerm provider version is compatible with terraform core/ cli version such that it supports azurerm provider version in order to create
authorization rules smoothly.
Related
When I ran init:
Initializing modules...
Initializing the backend...
Initializing provider plugins...
Finding cloudflare/cloudflare versions matching "~> 3.0"...
Finding latest version of hashicorp/cloudflare...
Installing cloudflare/cloudflare v3.31.0...
Installed cloudflare/cloudflare v3.31.0 (signed by a HashiCorp partner, key ID DE413CEC881C3283)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider hashicorp/cloudflare: provider registry registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/cloudflare
Did you intend to use cloudflare/cloudflare? If so, you must specify that source address in each module which requires that provider. To see which modules are currently
depending on hashicorp/cloudflare, run the following command:
terraform providers
Module:
cat dns.tf
module "dns" {
source = "./dns"
}
Definition:
cat cloudflare.tf
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 3.0"
}
}
}
provider "cloudflare" {
email = "CLOUDFLARE_EMAIL"
api_key = "CLOUDFLARE_API_KEY"
}
We've been using older versions of both Terraform and the azurerm provider and I'm trying to update the code for newer (for us) versions of each, in this case:
Terraform: v0.13.7
azurerm: v2.25
As part of the recoding, I'm switching to using the Terraform provider block:
terraform {
required_version = "~> 0.13"
required_providers {
azurerm = {
version = "= 2.25.0"
source = "hashicorp/azurerm"
}
}
}
provider azurerm {
skip_provider_registration = true
features {}
}
Terraform is downloading v2.25 of the provider but also the most version v2.67:
$ terraform init
Initializing the backend...
Initializing provider plugins...
- terraform.io/builtin/terraform is built in to Terraform
- Finding hashicorp/azurerm versions matching "2.25.0"...
- Finding latest version of -/azurerm...
- Installing hashicorp/azurerm v2.25.0...
- Installed hashicorp/azurerm v2.25.0 (signed by HashiCorp)
- Installing -/azurerm v2.67.0...
- Installed -/azurerm v2.67.0 (signed by HashiCorp)
So far this doesn't seem to be an issue, but I cannot understand why it's downloading multiple versions. Could it be because, in another code file which defines the backend (we use Azure storage for Terraform state), it's seeing that "azurerm" reference and treating it as a "new" one?
terraform {
backend azurerm {
container_name = "terraforminfra-v2"
key = "state/postgres.tfstate"
}
}
OK, I figured it out ... the "old" reference to the provider was still in the Terraform state, which I think is what was triggering the download of the most current version.
I assume I am using the latest version of azurerm:
provider "azurerm" {
version = "=2.34.0"
features {}
}
As soon as I add this resource to my tf script:
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/policy_assignment
I get this error when I do terraform init:
>terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/custom...
- Finding hashicorp/azurerm versions matching "2.34.0"...
- Installing hashicorp/azurerm v2.34.0...
- Installed hashicorp/azurerm v2.34.0 (signed by HashiCorp)
Error: Failed to install provider
Error while installing hashicorp/custom: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/custom
Am I missing any custom terraform provider? Looking at the Terraform documentation in the link above, I expect the azurerm_policy_definition resource must be included n the azurerm
Thanks to #ChristianPearce who deserves the credit for the answer.
This is a common and potentially misleading error.
There could me many scripting issues that cause this error.
In my case my resource name had typo in it like below:
resource "azurerm_virtual_network_typo_in_type" "main" {
This could also be a problem with terraform sub-modules as discussed in https://github.com/hashicorp/terraform/issues/25602.
For community providers, every module requires a required_providers block with an entry specifying the provider source.
So basically you need to have this in all your modules and in your main tf-script (replace the custom-prov-name by you actual provider):
terraform {
required_providers {
custom-prov-name = {
source = ".../custom-prov-name"
}
}
}
I'm getting this error when runnig Terraform validate or Terraform plan. What's strange is that the code used to work without a problem from my VsCode terminal window. The same code executes well if run from the Azure Command Shell. Any pointers would be great.
Error: Failed to instantiate provider "azuread" to obtain schema: Unrecognized remote plugin message:
This usually means that the plugin is either invalid or simply
needs to be recompiled to support the latest protocol.
Error: Failed to instantiate provider "azurerm" to obtain schema: Unrecognized remote plugin message:
This usually means that the plugin is either invalid or simply
needs to be recompiled to support the latest protocol.```
Here's the provider information:
```terraform {
required_version = "0.12.9"
}
provider "azurerm" {
version = "2.11"
subscription_id = "my first subscription id goes here"
features {}
}
provider "azurerm" {
version = "2.11"
alias = "shared"
subscription_id = "my second subscription id goes here"
features {}
}
provider "azuread" {
version = "0.11.0"
}```
The same issue resolved for me by using the bellow changes,
First In the main.tf file,
provider "azurerm" {
version = "=2.0.0"
features { }
}
Second run the upgrade command from Visual Studio Code for deploy the resources,
terraform init -upgrade
terraform init
terraform plan
terraform apply
I have the following resources to create a sql server and database using terraform
# Configure the Microsoft Azure Provider
provider "azurerm" {
version = "0.2.2"
}
# ...
resource "azurerm_sql_server" "demo" {
name = "${var.sql_server_name}"
resource_group_name = "${azurerm_resource_group.demo.name}"
location = "${azurerm_resource_group.demo.location}"
version = "12.0"
administrator_login = "${var.sql_server_account}"
administrator_login_password = "${var.sql_server_password}"
}
# Create SQL Database
resource "azurerm_sql_database" "demo" {
name = "demo"
resource_group_name = "${azurerm_resource_group.demo.name}"
location = "${azurerm_resource_group.demo.location}"
server_name = "${azurerm_sql_server.demo.name}"
}
When I run terraform plan it says it will create these resources, but when running terraform apply I get this error:
Error applying plan:
1 error(s) occurred:
* azurerm_sql_server.demo: 1 error(s) occurred:
* azurerm_sql_server.demo: sql.ServersClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="Unknown" Message="Unknown service error"
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
I tried changing the version of the azurerm plugin I'm using, but nothing has changed. I use the azurerm plugin version 0.2.2, same error occurs with versions 0.2.1, 0.2.0 does not work with some other resources.
It was silly, I looked into my azure logs and in turns out I was using the login name "admin" for sql server and that is not valid in the current version.
I guess Terraform has some problem to propogate the error from Azure to the command line.
In my case there was a mismatch with the values supplied to the variables:
edition requested_service_objective_name