地形。属性值不合适...需要字符串
Terraform. Inappropriate value for attribute ... string required
有没有办法将 Terraform 字符串列表中的每一项拆分为双引号并作为字符串输出格式?
我想将这个动态变量放在 permissions 参数中。
variables.tf
variable "ext_permissions" {
type = list(string)
default = ["iam.roles.list", "iam.roles.create", "iam.roles.delete"]
}
main.tf
resource "google_project_iam_custom_role" "my-custom-role" {
role_id = "myCustomRole"
title = "My Custom Role"
description = "A description"
permissions = ["iam.serviceAccounts.create","iam.serviceAccounts.getIamPolicy", "${var.ext_permissions}"]
}
错误:属性值类型不正确
var.ext_permissions is list of string with 2 elements Inappropriate
value for attribute "permissions": element 9: string required.
AFAIS 你需要列表连接,比如
concat(["a", "b"], ["c", "d"]) -> ["a", "b", "c", "d"]
或者您的情况:
permissions = concat(["iam.serviceAccounts.create","iam.serviceAccounts.getIamPolicy"], var.ext_permissions)
有没有办法将 Terraform 字符串列表中的每一项拆分为双引号并作为字符串输出格式? 我想将这个动态变量放在 permissions 参数中。
variables.tf
variable "ext_permissions" {
type = list(string)
default = ["iam.roles.list", "iam.roles.create", "iam.roles.delete"]
}
main.tf
resource "google_project_iam_custom_role" "my-custom-role" {
role_id = "myCustomRole"
title = "My Custom Role"
description = "A description"
permissions = ["iam.serviceAccounts.create","iam.serviceAccounts.getIamPolicy", "${var.ext_permissions}"]
}
错误:属性值类型不正确
var.ext_permissions is list of string with 2 elements Inappropriate value for attribute "permissions": element 9: string required.
AFAIS 你需要列表连接,比如
concat(["a", "b"], ["c", "d"]) -> ["a", "b", "c", "d"]
或者您的情况:
permissions = concat(["iam.serviceAccounts.create","iam.serviceAccounts.getIamPolicy"], var.ext_permissions)