2017-10-04 90 views
0

當創建SQL服務器,我有以下的資源使用terraform錯誤應用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}" 
} 

當我運行terraform計劃它說,它會創建這些資源,但運行時terraform適用於創建SQL服務器和數據庫我得到這個錯誤:

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不適用於其他資源。

回答

1

這很愚蠢,我看着我的天藍色日誌,事實證明我正在使用登錄名「admin」作爲sql server,而這在當前版本中是無效的。