fardin
fardin

Reputation: 1477

Join two strings in Terraform

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.

Upvotes: 2

Views: 3389

Answers (1)

Alain O'Dea
Alain O'Dea

Reputation: 21716

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}"
}

Upvotes: 4

Related Questions