vas*_*hth 7 terraform terraform-provider-azure
我正在尝试在 terraform tfvars 变量上使用 terraform 字符串函数和字符串连接。但是当运行 terraform 计划时,它会通过以下异常
错误:对资源类型的引用必须后跟至少一个属性访问,指定资源名称。
以下是地形代码
locals {
name_suffix = "${var.namespace != "" ? var.namespace : var.env}"
}
resource "azurerm_container_registry" "my_acr" {
name = "myacr${replace(name_suffix, "-", "")}"
location = "${azurerm_resource_group.location}"
resource_group_name = "${azurerm_resource_group.name}"
sku = "Basic"
admin_enabled = true
}
Run Code Online (Sandbox Code Playgroud)
这里命名空间值将在运行时解析。
Terraform 版本 0.12.7
Pro*_*ton 20
为 AWS Fargate 设置 Terraform 配置文件时遇到类似问题。
\n得到以下错误:
\n\xe2\x94\x82 Error: Invalid reference\n\xe2\x94\x82 \n\xe2\x94\x82 on ../ecs/main.tf line 72, in resource "aws_ecs_service" "aes":\n\xe2\x94\x82 72: type = order_placement_type\n\xe2\x94\x82 \n\xe2\x94\x82 A reference to a resource type must be followed by at least one attribute access, specifying the resource name.\n\xe2\x95\xb5\n\xe2\x95\xb7\n\xe2\x94\x82 Error: Invalid reference\n\xe2\x94\x82 \n\xe2\x94\x82 on ../ecs/main.tf line 73, in resource "aws_ecs_service" "aes":\n\xe2\x94\x82 73: field = order_placement_field\n\xe2\x94\x82 \n\xe2\x94\x82 A reference to a resource type must be followed by at least one attribute access, specifying the resource name.\nRun Code Online (Sandbox Code Playgroud)\n问题是我错过了var变量的前缀,所以不是这样的:
ordered_placement_strategy {\n type = order_placement_type\n field = order_placement_field\n}\nRun Code Online (Sandbox Code Playgroud)\n我将其更正为:
\nordered_placement_strategy {\n type = var.order_placement_type\n field = var.order_placement_field\n}\nRun Code Online (Sandbox Code Playgroud)\n就这样。
\n| 归档时间: |
|
| 查看次数: |
9810 次 |
| 最近记录: |