From 6eadab9c4261d575485693f03341cb69da40919f Mon Sep 17 00:00:00 2001 From: badra001 Date: Tue, 18 Jan 2022 10:06:47 -0500 Subject: [PATCH] add subnet_interface_*_map --- vpc-interface-endpoint/README.md | 1 + vpc-interface-endpoint/outputs.tf | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/vpc-interface-endpoint/README.md b/vpc-interface-endpoint/README.md index 54c9d3e..987c8f6 100644 --- a/vpc-interface-endpoint/README.md +++ b/vpc-interface-endpoint/README.md @@ -53,6 +53,7 @@ No modules. | [aws_vpc_endpoint.interface_endpoint](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_endpoint) | resource | | [aws_arn.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source | | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | +| [aws_network_interface.vpce_interfaces](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/network_interface) | data source | | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | | [aws_vpc_endpoint_service.interface_endpoint](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc_endpoint_service) | data source | diff --git a/vpc-interface-endpoint/outputs.tf b/vpc-interface-endpoint/outputs.tf index 3d47cdd..9aff205 100644 --- a/vpc-interface-endpoint/outputs.tf +++ b/vpc-interface-endpoint/outputs.tf @@ -1,12 +1,18 @@ +data "aws_network_interface" "vpce_interfaces" { + for_each = toset(aws_vpc_endpoint.interface_endpoint.network_interface_ids) + id = each.key +} + output "vpce_service_info" { description = "VPC Interface Endpoint information for service" value = { - "name" = local.short_service, - "service_name" = aws_vpc_endpoint.interface_endpoint.service_name, - "id" = aws_vpc_endpoint.interface_endpoint.id, - "dns_entry" = aws_vpc_endpoint.interface_endpoint.dns_entry, - "subnet_ids" = aws_vpc_endpoint.interface_endpoint.subnet_ids, - "network_interface_ids" = aws_vpc_endpoint.interface_endpoint.network_interface_ids, - "subnet_ip_map" = zipmap(tolist(aws_vpc_endpoint.interface_endpoint.subnet_ids), tolist(aws_vpc_endpoint.interface_endpoint.network_interface_ids)), + "name" = local.short_service, + "service_name" = aws_vpc_endpoint.interface_endpoint.service_name, + "id" = aws_vpc_endpoint.interface_endpoint.id, + "dns_entry" = aws_vpc_endpoint.interface_endpoint.dns_entry, + "subnet_ids" = aws_vpc_endpoint.interface_endpoint.subnet_ids, + "network_interface_ids" = aws_vpc_endpoint.interface_endpoint.network_interface_ids, + "subnet_interface_id_map" = zipmap(tolist(aws_vpc_endpoint.interface_endpoint.subnet_ids), tolist(aws_vpc_endpoint.interface_endpoint.network_interface_ids)), + "subnet_interface_ip_map" = zipmap(tolist(aws_vpc_endpoint.interface_endpoint.subnet_ids), [for k, v in data.aws_network_interface.vpce_interfaces : v.private_ip]), } }