Skip to content

Instantly share code, notes, and snippets.

@atz
Last active December 6, 2018 23:58
Show Gist options
  • Save atz/9e2e60e3454921f3594d6dbc681bb4ba to your computer and use it in GitHub Desktop.
Save atz/9e2e60e3454921f3594d6dbc681bb4ba to your computer and use it in GitHub Desktop.
Terraform list-in/list-out operational
module "example1" {
source = "./list"
}
module "example2" {
source = "./list"
values = ["this", "that", "other"]
}
module "example3" {
source = "./list"
values = ["${module.example2.many}"]
}
module "example4" {
source = "./list"
values = ["${module.example2.many}", "extra"]
}
output "many" {
value = ["${var.values}"]
}
variable "values" {
type = "list"
default = ["first", "second", "third"]
}
output "example1_vals" {
value = ["${module.example1.many}"]
}
output "example2_vals" {
value = ["${module.example2.many}"]
}
output "example3_vals" {
value = ["${module.example3.many}"]
}
output "example4_vals" {
value = ["${module.example4.many}"]
}
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Releasing state lock. This may take a few moments...
Outputs:
example1_vals = [
first,
second,
third
]
example2_vals = [
this,
that,
other
]
example3_vals = [
this,
that,
other
]
example4_vals = [
this,
that,
other,
extra
]
@atz
Copy link
Author

atz commented Dec 6, 2018

To compensate for lack of subdirs in gists, after pulling:

mkdir list
mv list_output.tf list/output.tf
mv list_variables.tf list/variables.tf
terraform apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment