'Format error while using join function in Terraform
I would need to have joined values from schemasREAD.usage_roles together with string suffix "_R" ultimately creating a role in resource "warehouse_grant_usageREAD_R" called "PROD_FINANCE_DELIVERY_COMMONDATA_READER_R" however getting following error when using "join" function:
│ on schemas.tf line 62, in resource "snowflake_warehouse_grant" "warehouse_grant_usageREAD_R":
│ 62: roles = "${join("", [ "${each.value.usage_roles}" , "_R"])}"
│ ├────────────────
│ │ each.value.usage_roles will be known only after apply
│
│ Inappropriate value for attribute "roles": set of string required.
Structure looks as following:
locals {
schemasREAD = {
"COMMONDATA" = {
database = "PROD_FINANCE_DELIVERY"
usage_roles = ["PROD_FINANCE_DELIVERY_COMMONDATA_READER"]
}
}
}
resource "snowflake_warehouse_grant" "warehouse_grant_usageREAD_R" {
depends_on = [snowflake_role.role]
for_each = local.schemasREAD
warehouse_name = "PROD_FINANCE_DELIVERY_LOAD_WH"
privilege = "USAGE"
roles = "${join("", [ "${each.value.usage_roles}" , "_R"])}"
with_grant_option = false
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
