I'm creating a series of s3 buckets with this definition:
resource "aws_s3_bucket" "map" { for_each = local.bucket_settings bucket = each.key ... }
I'd like to output a list of the website endpoints:
output "website_endpoints" { # value = aws_s3_bucket.map["example.com"].website_endpoint value = ["${keys(aws_s3_bucket.map)}"] }
What's the syntax to pull out a list of the endpoints (rather than the full object properties)?
If you just want to get a list of website_endpoint, then you can do:
list
website_endpoint
output "website_endpoints" { value = values(aws_s3_bucket.map)[*].website_endpoint }
This uses splat expression.
2.1m questions
2.1m answers
60 comments
57.0k users