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
Related
I'm using terraform and terragrunt to create some repositories in bitbucket, and since they do not have an official provider I'm using one from DrFaust92/bitbucket. I have done everything in my computer and I could apply all, now I'm moving the workflow to circle ci, and when I run it there I always get this error:
bitbucket_repository.repository: Creating...
╷
│ Error: Empty Summary: This is always a bug in the provider and should be reported
to the provider developers.
│
│ with bitbucket_repository.repository,
│ on main.tf line 5, in resource "bitbucket_repository" "repository":
│ 5: resource "bitbucket_repository" "repository" {
The resource does not have anything in special:
resource "bitbucket_repository" "repository" {
name = var.name
description = var.description
owner = var.owner
project_key = var.project_key
language = var.project_language
fork_policy = var.fork_policy
is_private = true
}
I'm using terraform 1.3.7 and terragrunt 0.43.1 (in my computer and in circle ci, both run with the same versions). It fails when it access any tfstate: if the tfstate already exists, it throws the error when planning, if it doesn't, the plan runs well, but when I apply it fails with the same error.
Any help to fix this will be appreciated!
This is most likely issue associated with provider version. In your local, it may have a certain version downloaded/cached. Within Circle CI, it may be fetching latest provider that is available(which may have some issues). I would suggest you find the provider version currently in use locally, and then add required_providers block accordingly to make sure that it uses the same version of the provider. You can find the version presently in use from the terminal output that is generated on 'terraform init'. Below is the sample block to specify specific provider version(taken from: https://registry.terraform.io/providers/aeirola/bitbucket/latest/docs/resources/repository).
terraform {
required_providers {
bitbucket = {
source = "DrFaust92/bitbucket"
version = "v2.30.0"
}
}
}
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.
Context: I'm developing a new TF provider. In order to test it, I use the following piece of advice from TF docs:
provider_installation {
# Use /home/developer/tmp/terraform-null as an overridden package directory
# for the hashicorp/null provider. This disables the version and checksum
# verifications for this provider and forces Terraform to look for the
# null provider plugin in the given directory.
dev_overrides {
"hashicorp/null" = "/home/developer/tmp/terraform-null"
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
And when I run terraform plan / terraform apply my provider does work without any issues. However when I try to run terraform init I'm running into:
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider
hashicorp/null: could not connect to hashicorp: Failed
to request discovery document: Get
"https://hashicorp/.well-known/terraform.json": dial tcp: lookup hashicorp on
100.217.9.1:53: no such host
Is there a way I could fix it?
For the context, my main.tf file starts with
terraform {
required_providers {
null = {
source = "hashicorp/null"
}
}
}
When I googled around, I found a related blog post and terraform plan seems to work for the author since he doesn't uses other plugins which is not the case for me unfortunately.
This issue on GitHub seems to show the same issues.
I am trying to automate the deployment of VM's in Vcloud using terraform.
The server that I am using doesn't have an internet connection so I had to install terraform and VCD provider offline.
Terrafom init worked but when I use terraform plan is crashing...
Terraform version: 1.0.11
VCD provider version: 3.2.0(I am using this version because we have vcloud 9.7).
This is a testing script, to see if terraform works
terraform {
required_providers {
vcd = {
source = "vmware/vcd"
version = "3.2.0"
}
}
}
provider "vcd" {
user = "test"
password = "test"
url = "https://test/api"
auth_type = "integrated"
vdc = "Org1VDC"
org = "System"
max_retry_timeout = "60"
allow_unverified_ssl = "true"
}
resource "vcd_org_user" "my-org-admin" {
org = "my-org"
name = "my-org-admin"
description = "a new org admin"
role = "Organization Administrator"
password = "change-me"
}
When I run terraform plan I get the following error:
Error: Plugin did not respond
...
The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ConfigureProvider call. The plugin logs may contain more details
Stack trace from the terraform-provider-vcd_v3.2.0 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xaf3b75]
...
Error: The terraform-provider-vcd_v3.2.0 plugin crashed!
In the logs I can see a lot of DEBUG messages where the provider is trying to connect to github. provider.terraform-provider-vcd_v3.2.0: github.com/vmware/go-vcloud-director/v2/govcd.(*VCDClient).Authenticate(...)
And for ERROR messages I only saw 2:
plugin.(*GRPCProvider).ConfigureProvider: error="rpc error: code = Unavailable desc = transport is closing"
Failed to read plugin lock file .terraform/plugins/linux_amd64/lock.json: open .terraform/plugins/linux_amd64/lock.json: no such file or directory
This is the first time when am I am configuring Terraform offline and am using VCD provider.
Did I miss something?
I have found the issue.
At the URL I was using the IP address of the Vcloud api, and for some reason terraform didn't like that and was causing the crash, after changing to the FQDN, terraform started working again.
Kind regards
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