Error: Invalid provider configuration alias

Error: Invalid provider configuration alias

升级到版本 Terraform v0.12.0 并使用 "terraform 0.12upgrade"

更新配置后

我在 terraform init 中收到以下错误

别名设置为 main.tf 中的变量,并从 azure 传入或替换。

There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that Terraform can determine which modules and providers need to be installed.

Error: Invalid provider configuration alias

An alias must be a valid name. A name must start with a letter and may contain only letters, digits, underscores, and dashes.

 `provider "azurerm {
  subscription_id = var.arm_subscription_id
  tenant_id       = var.tenant_id
  alias           = "$${var.myservers_name}"
}`"

您在提供的提供商代码中存在一些错误。代码应如下所示更改:

provider "azurerm" {

  version = ">=1.2.0"
  alias = "${var.alias_name}"

  subscription_id = "${var.arm_subscription_id}"
  tenant_id       = "${var.tenant_id}"  
}

看来你用的是Azure Provider: Authenticating using the Azure CLI。当你想引用已经设置的变量时,你需要使用像 "${var.var_name}" 这样的代码。