Skip to content

Commit d1a6b76

Browse files
authored
Merge pull request #70 from JakubCzarniecki/support-ram-sharing-for-externally-managed-services
Add externally managed services to RAM share
2 parents a2fa2e0 + 85bf05b commit d1a6b76

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

data.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ locals {
4343
share_service_network = local.config_ram_share ? local.create_service_network && try(var.ram_share.share_service_network, true) : false
4444
# Default of var.ram_share.share_services - if not defined, all the created services will be included
4545
share_services = try(var.ram_share.share_services, keys(var.services))
46+
# Support RAM share of services managed by the module as well as external ones
47+
ram_services_association_resources = {
48+
for svc in local.share_services :
49+
svc => lookup(
50+
aws_vpclattice_service.lattice_service,
51+
svc,
52+
lookup(
53+
data.aws_vpclattice_service.lattice_service,
54+
svc,
55+
null
56+
)
57+
)
58+
}
4659
# Move var.ram_share.principals from list(string) to map(string)
4760
principals_map = { for index, principal in try(var.ram_share.principals, []) : index => principal }
4861
}

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,6 @@ resource "aws_ram_resource_association" "ram_service_network_association" {
278278
resource "aws_ram_resource_association" "ram_services_association" {
279279
count = local.config_ram_share ? length(local.share_services) : 0
280280

281-
resource_arn = aws_vpclattice_service.lattice_service[local.share_services[count.index]].arn
281+
resource_arn = local.ram_services_association_resources[local.share_services[count.index]].arn
282282
resource_share_arn = local.resource_share_arn
283283
}

0 commit comments

Comments
 (0)