generated from appvia/terraform-aws-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathram.tf
26 lines (20 loc) · 1002 Bytes
/
ram.tf
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
## Provision the AWS RAM share - so we can share the rules with other accounts
resource "aws_ram_resource_share" "endpoints" {
for_each = local.endpoints_rules
allow_external_principals = true
name = format("%s-%s-endpoints", var.sharing.share_prefix, each.value.service)
tags = merge(var.tags, { "Name" : format("%s-%s-endpoints", var.sharing.share_prefix, each.value.service) })
}
## Associate each of the resolver rules with the resource share
resource "aws_ram_resource_association" "endpoints" {
for_each = local.endpoints_rules
resource_arn = aws_route53_resolver_rule.endpoints[each.key].arn
resource_share_arn = aws_ram_resource_share.endpoints[each.key].arn
}
## Associate the ram shares with the principals
module "ram_share" {
for_each = local.endpoints_rules
source = "./modules/ram_share"
ram_principals = var.sharing.principals
ram_resource_share_arn = aws_ram_resource_share.endpoints[each.key].arn
}