Terraform应该运行良好。但是,抛出错误,未为“ sku”的azurerm_automation_account设置“ sku”,这对于资源是可选的。
> agent/main.tf
module "security" {
source = "../security"
env = "${var.env}"
location = "${var.location}"
}
> security/main.tf
resource "azurerm_automation_account" "aut_acc" {
depends_on = ["azurerm_storage_blob.blobobject"]
name = "GAV-ARV-${var.env}-AUT-ACC-01"
location = "${azurerm_resource_group.rg_aut.location}"
resource_group_name = "${azurerm_resource_group.rg_aut.name}"
}
> security/var.tf
variable "env" {
description = "The env being deployed to (dev, qa, stg, prd)"
default = "dev"
}
variable "location" {
description = "The location of the resources being created"
default = "westus"
}
答案 0 :(得分:0)
它显示属性sku
应该是可选参数,但实际上,根据我的测试,它是必需参数。另外,sku
将被弃用。因此,我建议您使用参数sku_name
。支持值为“基本”和“免费”。因此该块应如下所示:
resource "azurerm_automation_account" "aut_acc" {
depends_on = ["azurerm_storage_blob.blobobject"]
name = "GAV-ARV-${var.env}-AUT-ACC-01"
location = "${azurerm_resource_group.rg_aut.location}"
resource_group_name = "${azurerm_resource_group.rg_aut.name}"
sku_name = "Basic" # or "Free"
}
注意:正如我所看到的,自动化帐户并不需要'depends_on'。
答案 1 :(得分:0)
这似乎是Azurerm提供程序terraform的1.29.0版中的错误。将版本更新到1.32.0之后,它得到了修复,并且可选参数也没有抛出异常。
provider "azurerm" {
version = "=1.32.0"
subscription_id = "${var.subscription}"
client_id = "${var.service_principal_name}"
client_secret = "${var.service_principal_secret}"
tenant_id = "${var.tenantId}"
}