Created
December 10, 2020 21:30
-
-
Save straubt1/7aa550c0851eb94d689b5531ceaba95f to your computer and use it in GitHub Desktop.
Multiple VPC Endpoint Lookup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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