【发布时间】:2018-11-24 03:30:32
【问题描述】:
我正在尝试使用变量文件来使用 Terraform 在 Azure 中部署资源组,但如果我只有一个变量,它就可以工作。如果我使用两个,我会得到一个错误:
“标志-var-file的无效值“variables.tf”:多个映射 变量不支持声明”
变量文件如下:
variable "resource_group_name" {
description = "The name of the resource group in which the resources will be created"
default = "im-from-the-variables-file"
}
variable "location" {
description = "The location/region where the virtual network is created. Changing this forces a new resource to be created."
default = "west europe"
}
用于部署的主要文件如下:
resource "azurerm_resource_group" "vm" {
name = "${var.resource_group_name}"
location = "${var.location}"
}
【问题讨论】:
-
您使用
-var-file传递的 tfvars 文件是什么样的? -
第一块代码:variable "resource_group_name" { description = "将在其中创建资源的资源组的名称" default = "im-from-the-variables-file" } variable "location" { description = "创建虚拟网络的位置/区域。更改它会强制创建新资源。"默认=“西欧”}