0

我有以下资源可以使用 terraform 创建 sql server 和数据库

# 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}"
}

当我运行 terraform plan 时,它说它将创建这些资源,但是在运行 terraform apply 时出现此错误:

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.

我尝试更改正在使用的 azurerm 插件的版本,但没有任何改变。我使用 azurerm 插件版本 0.2.2,版本 0.2.1 出现同样的错误,0.2.0 不适用于其他一些资源。

4

2 回答 2

1

这很愚蠢,我查看了我的 azure 日志,结果发现我使用的是 sql server 的登录名“admin”,这在当前版本中无效。

于 2017-10-04T14:39:08.987 回答
0

我猜 Terraform 在将错误从 Azure 传播到命令行方面存在一些问题。

在我的情况下,提供给变量的值不匹配: edition requested_service_objective_name

于 2019-02-19T11:06:48.713 回答