Join two strings in Terraform

Viewed 886

I have two strings in Terraform:

"1.1.1.1,2.2.2.2"

"3.3.3.3,4.4.4.4"

How do I get

"1.1.1.1,2.2.2.2,3.3.3.3,4.4.4.4"

Seems very trivial, but could not find a function/workaround for it.

1 Answers

string templates and join are the immediate solutions I reach for:

locals {
  string1 = "1.1.1.1,2.2.2.2"

  string2 = "3.3.3.3,4.4.4.4"

  strings_join = join(",", [local.string1, local.string2])

  strings_template = "${local.string1},${local.string2}"
}
Related