Last active
February 23, 2021 22:55
-
-
Save arkag/ca5aa060da1ce76e80a002c996e98a92 to your computer and use it in GitHub Desktop.
logic to clean out animal names that are less than safe for work
This file contains hidden or 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
resource "random_pet" "server_name" { | |
count = 1000 | |
length = 4 | |
separator = local.name_sep | |
prefix = null | |
} | |
locals { | |
no_no_words = { | |
jackass = "hinny" | |
woodcock = "woodhen" | |
} | |
name_sep = "-" | |
sfw_names = [for name in random_pet.server_name[*].id : contains(keys(local.no_no_words), split(local.name_sep, name)[length(split(local.name_sep, name))-1]) ? replace(name, split(local.name_sep, name)[length(split(local.name_sep, name))-1], local.no_no_words[split(local.name_sep, name)[length(split(local.name_sep, name))-1]]) : name] | |
} | |
output "dns" { | |
value = [for name in local.sfw_names : join("", [name, ".", "domain.com"])] | |
description = "the dns entries for each server" | |
} | |
output "length" { | |
value = length(local.sfw_names) | |
description = "the dns entries for each server" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment