1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# locals =======================================================================
data "aws_availability_zones" "available" { state = "available" }
locals {
region_abbr = split("-", data.aws_availability_zones.available.zone_ids[0])[0]
share_names = {
for k, v in var.resource_shares :
k => "${var.name_prefix}-${local.region_abbr}-${v.name_suffix}"
}
module_tags = {
managed-by = "terraform"
module-name = "network:ram-share"
}
# Flatten resource_arns lists per share into a single association map
resource_association_map = {
for item in flatten([
for k, v in var.resource_shares : [
for idx, arn in v.resource_arns : {
key = "${k}-resource-${format("%02d", idx + 1)}"
share_key = k
arn = arn
}
]
]) : item.key => item
}
# Flatten principals lists per share into a single association map
principal_association_map = {
for item in flatten([
for k, v in var.resource_shares : [
for idx, principal in v.principals : {
key = "${k}-principal-${format("%02d", idx + 1)}"
share_key = k
principal = principal
}
]
]) : item.key => item
}
}
|