Created
August 26, 2022 07:53
-
-
Save leslie-alldridge/c1f38dda3467cb744e53629878a1fdbd to your computer and use it in GitHub Desktop.
terraform substring contains
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
locals { | |
rg_string = "rg-d-lxr-aus-app1" | |
// Use split by - to create an array so we can use contains() | |
is_rg = contains(split("-", local.rg_string), "rg") | |
final_rg_string = local.is_rg ? replace(local.rg_string, "aus-", "") : local.rg_string | |
not_rg_string = "blah-d-lxr-aus-app1" | |
is_not_rg = contains(split("-", local.not_rg_string), "rg") | |
final_not_rg_string = local.is_not_rg ? replace(local.not_rg_string, "aus-", "") : local.not_rg_string | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment