Search code examples
arrayslistterraformhcl

Convert terraform array to string


I have a terraform array/list

r53_zone_names = [
  "google.com.",
  "example.com.",
]

But I wish to convert it to sting for sending it to external-dns helm chart, it asks for such one:

"{google.com.,example.com.}"

How to do that with HCL? Terraform v1.3.7


Solution

  • Using format and join:

    > format("{%s}",join(",",local.r53_zone_names))
    "{google.com.,example.com.}"