Search code examples
terraformhcl

How to initialize list in Terraform?


I want to create a variable that has a single value, a list of elements. So I did:

variable "cipher_suites" = {
     type    = list(string)
     default =  [
      "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
      "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
     ]
}

and this

   variable "cipher_suites" {
         type    = "list"
         default =  [
          "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
          "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
         ]
    }

but then I get a lot of errors like this regarding my declaration and initialization:

This character is not used
2019-10-09T06:41:12.2239556Z within the language.

What am I doing wrong here?


Solution

  • This is the rigth way, and it works for me.

     variable "cipher_suites" {
             type    = list(string)
             default =  [
              "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
              "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
             ]
        }
    

    Hope it help, if this don't work for you, probably is another error, maybe some imports or something like that.