Skip to content

Commit

Permalink
add subnet_interface_*_map
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Jan 18, 2022
1 parent b75dc1c commit 6eadab9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions vpc-interface-endpoint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
20 changes: 13 additions & 7 deletions vpc-interface-endpoint/outputs.tf
Original file line number Diff line number Diff line change
@@ -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]),
}
}

0 comments on commit 6eadab9

Please sign in to comment.