patternterraformMinor
Are multiline lists valid in Terraform?
Viewed 0 times
multilinearevalidliststerraform
Problem
I currently have the following.
This clearly makes the
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"
]Solution
Yes. According to Types and Values: 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:
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].
Context
StackExchange DevOps Q#14746, answer score: 7
Revisions (0)
No revisions yet.