Answers: <p>Yes. According to <a href="https://www.terraform.io/docs/language/expressions/types.html#lists-tuples" rel="noreferrer">Types and Values: Lists/Tuples</a></p>
  <blockquote>
  <p>List literals can be split into multiple lines for readability, but always require a comma between values. A comma after the final value is allowed, but not required. Values in a list can be arbitrary expressions.</p>
  </blockquote>
  <p>Source:</p>
  <ul>
  <li>Terraform by HashiCorp. (n.d.). Types and Values - Configuration Language. [online] Available at: <a href="https://www.terraform.io/docs/language/expressions/types.html#lists-tuples" rel="noreferrer">https://www.terraform.io/docs/language/expressions/types.html#lists-tuples</a> [Accessed 28 Sep. 2021].</li>
  </ul>
  <p>‌</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-09-28T11:39:36.237Z
Answers: Found the answer while writing the question so did not want it to go to waste :)
Answers: James Geddes
Answers: CC BY-SA 4.0
Answers: 2021-09-28T12:38:03.773Z
Answers: If you work with AWS/IAM + Terraform, you will see modules that have 1 IAM roles with 1 to many policies attached to it and it usually goes as a manual arn list or a data source holding that arn. Thats what I have seen in my work experience as big/long lists. So good job for finding this and its a valid answer!
Answers: Kristian Kanchev
Answers: CC BY-SA 4.0
Answers: 2021-09-28T18:02:06.583Z
Answers: These docs are written to describe specific situations in specific terms, but it might interest you to know a more general rule: when parsing expressions (the right-hand side of an `=` for an attribute inside a block) Terraform treats newlines as irrelevant whitespace inside both parentheses and square brackets, unless you undo that effect inside by opening braces (where the newline-sensitive processing comes back into effect again, so you can use newline-separated attribute syntax to define the object attributes).
Answers: Martin Atkins
Answers: CC BY-SA 4.0
Answers: 2021-09-28T11:38:59.837Z
Answers: 2021-09-28T11:38:59.837Z
Answers: James Geddes
Body: <p>I currently have the following.</p>
  <pre><code>module &quot;module-name&quot; {
    source                              = &quot;./directory&quot;
    environment                         = var.environment
    team_names                          = [&quot;team-a&quot;, &quot;team-b&quot;, &quot;team-c&quot;, &quot;team-d&quot;]
  </code></pre>
  <p>This clearly makes the <code>team_names</code> line very long. Is it valid to change to this?</p>
  <pre><code>module &quot;module-name&quot; {
    source                              = &quot;./directory&quot;
    environment                         = var.environment
    team_names                          = [
                                            &quot;team-a&quot;,
                                            &quot;team-b&quot;,
                                            &quot;team-c&quot;,
                                            &quot;team-d&quot;
                                          ]
  </code></pre>
  
Tags: <terraform>
Title: Are multiline lists valid in Terraform?
UserDisplayName: James Geddes
ThreadText: # Are multiline lists valid in Terraform?
  
  (Asked by: username_0 on 2021-09-28)
  
  I currently have the following.
  
  ```
  module "module-name" {
    source                              = "./directory"
    environment                         = var.environment
    team_names                          = ["team-a", "team-b", "team-c", "team-d"]
  
  ```
  
  This clearly makes the `team_names` line very long. Is it valid to change to this?
  
  ```
  module "module-name" {
    source                              = "./directory"
    environment                         = var.environment
    team_names                          = [
                                            "team-a",
                                            "team-b",
                                            "team-c",
                                            "team-d"
                                          ]
  
  ```
  
  **Tags:** terraform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-09-28. Score: 7
  
  Yes. According to [Types and Values: Lists/Tuples](https://www.terraform.io/docs/language/expressions/types.html#lists-tuples)
  
  > List literals can be split into multiple lines for readability, but always require a comma between values. A comma after the final value is allowed, but not required. Values in a list can be arbitrary expressions.
  
  Source:
  
  * Terraform by HashiCorp. (n.d.). Types and Values - Configuration Language. [online] Available at: <https://www.terraform.io/docs/language/expressions/types.html#lists-tuples> [Accessed 28 Sep. 2021].
  
  ‌
  
  > **Comments:**
  > **username_0**: Found the answer while writing the question so did not want it to go to waste :)  
  > **username_1**: If you work with AWS/IAM + Terraform, you will see modules that have 1 IAM roles with 1 to many policies attached to it and it usually goes as a manual arn list or a data source holding that arn. Thats what I have seen in my work experience as big/long lists. So good job for finding this and its a valid answer!  
  > **username_2**: These docs are written to describe specific situations in specific terms, but it might interest you to know a more general rule: when parsing expressions (the right-hand side of an `=` for an attribute inside a block) Terraform treats newlines as irrelevant whitespace inside both parentheses and square brackets, unless you undo that effect inside by opening braces (where the newline-sensitive processing comes back into effect again, so you can use newline-separated attribute syntax to define the object attributes).  
  
  ---
  
  