Skip to content

Instantly share code, notes, and snippets.

@karl-cardenas-coding
Last active March 8, 2020 00:05
Show Gist options
  • Save karl-cardenas-coding/9a898590e200831f065ef19f41418949 to your computer and use it in GitHub Desktop.
Save karl-cardenas-coding/9a898590e200831f065ef19f41418949 to your computer and use it in GitHub Desktop.
For loop in Terraform
locals {
s3_ips = try(distinct([ #distinct() is not needed but added to showcase the wrap of functions before the loop
for items in jsondecode(data.http.primary-server.body).prefixes:
items.ip_prefix if items.service == "S3"
]), "NO LIST PROVIDED IN LOCALS S3_IPS VARIABLE")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment