Closed adambarreiro closed 2 months ago
I guess I should manage a structure like this:
shared_with {
user_id = data.vcd_org_user.ac-admin1.id
access_level = "FullControl"
}
shared_with {
user_id = data.vcd_org_user.ac-vapp-creator2.id
access_level = "Change"
}
shared_with {
org_id = data.vcd_org.another-org.id
access_level = "ReadOnly"
}
correct?
I guess I should manage a structure like this: ... correct?
Yes, with this new data source you could then do something like:
output "user_ids" {
value = tolist(data.vcd_catalog_access_control.ac_ds.shared_with).*.user_id
}
Which could output, for example:
user_ids = tolist([
"urn:vcloud:user:02a6354f-af65-48e3-bdb4-b863b5c48267",
"urn:vcloud:user:915586cc-2a17-406d-a384-b895d42f66f7",
"urn:vcloud:user:a1d7ba06-dce8-4547-aef9-90be200351ab",
])
Then you can use dynamic blocks with them, reference by index or other usages
I do something like this, thanks
data "vcd_catalog" "shared_catalog" {
org = local.org_name
name = local.catalog_name
}
data "vcd_catalog_access_control" "shared_catalog_ac" {
catalog_id = data.vcd_catalog.shared_catalog.id
}
import {
to = vcd_catalog_access_control.shared_catalog_ac
id = "${local.org_name}.${local.catalog_name}"
}
resource "vcd_catalog_access_control" "shared_catalog_ac" {
org = local.org_name
catalog_id = data.vcd_catalog.shared_catalog.id
shared_with_everyone = false
# catalog is already shared with these entities
dynamic "shared_with" {
for_each = data.vcd_catalog_access_control.shared_catalog_ac.shared_with
content {
access_level = shared_with.value.access_level
group_id = shared_with.value.group_id
org_id = shared_with.value.org_id
user_id = shared_with.value.user_id
}
}
# this org added to catalog shared with
shared_with {
access_level = "ReadOnly"
org_id = vcd_org.org.id
}
}
Closes #1209
Adds a
vcd_catalog_access_control
data source to be able to read its properties from an existing Catalog.