0

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.

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.