Hi,
I am trying to use databricks_grants resource together with for_each meta-argument.
My code:
locals {
groups = ["group1", "group2"]
}
resource "databricks_grants" "catalog_grants" {
catalog = databricks_catalog.catalog_raw.name
for_each = toset(local.groups)
grant {
principal = local.service_principal_id
privileges = ["ALL_PRIVILEGES"]
}
grant {
principal = each.key
privileges = ["ALL_PRIVILEGES"]
}
}
I’d like to assign grants for databricks catalogs to list of groups, using for_each. As you can see, I assign not just one but multiple grants to this catalog. I understand, that each loop will most likely overwrite service principal’s grant, but at the end it should stay, so let’s ignore it. However, same thing happens for my groups variable - the last group overwrites itself as principal in the grant, and at the end catalog has only 2 grants - one for service principal and one for the group ( I expect to get three - one for service principal, and one for each of two groups). Is this limitation of terraform, databricks provider, or am I simply using it wrong ?