Skip to content

Instantly share code, notes, and snippets.

@straubt1
Created December 10, 2020 21:30
Show Gist options
  • Save straubt1/7aa550c0851eb94d689b5531ceaba95f to your computer and use it in GitHub Desktop.
Save straubt1/7aa550c0851eb94d689b5531ceaba95f to your computer and use it in GitHub Desktop.
Multiple VPC Endpoint Lookup
locals {
vpc_id = "vpc-xxxxx"
endpoints = [
"com.amazonaws.us-west-2.s3",
"com.amazonaws.us-west-2.ec2",
"com.amazonaws.us-west-2.rds",
]
}
data "aws_vpc_endpoint" "endpoints-foreach" {
for_each = toset(local.endpoints)
vpc_id = local.vpc_id
service_name = each.value
}
output "endpoints-foreach" {
value = [for ve in data.aws_vpc_endpoint.endpoints-foreach: ve.arn]
}
data "aws_vpc_endpoint" "endpoints-count" {
count = length(local.endpoints)
vpc_id = local.vpc_id
service_name = local.endpoints[count.index]
}
output "endpoints-count" {
value = data.aws_vpc_endpoint.endpoints-count.*.arn
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment