Skip to content

Instantly share code, notes, and snippets.

@KyMidd

KyMidd/asdf.tf Secret

Created January 3, 2024 22:27
Show Gist options
  • Select an option

  • Save KyMidd/632b0c483008ed04501c4a7cff2e7bc5 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/632b0c483008ed04501c4a7cff2e7bc5 to your computer and use it in GitHub Desktop.
locals {
# Iterate through all the country IP-lists and create a list of maps for each one
country_attribute_list = [
for country in fileset("${path.module}/ip_lists_by_country", "*") : {
# Read the 2/3-character short code at the beginning of each name
country_short_code = split("_", country)[0]
# Read the whole file-name in case we'll use it in future
country_name = replace(country, ".txt", "")
# Read the entire list of IPs for each country, then split into list using \n as delimiter
# Then use compact to remove any empty strings from the list
country_ips = compact(
split("\n", file("${path.module}/ip_lists_by_country/${country}"))
)
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment