Terraform v0.7.0-rc3 (3f4857a07a24f3c9e2db6b4458fbf5be19a8b256)
// Works for a single map, does not work for a list of maps
variable "vars" {
type = "map"
default = {
foo = "bar"
}
}
data "template_file" "file" {
template = "foo=${foo}"
vars = "${var.vars}"
}
output "output" {
value = "${data.template_file.file.rendered}"
}
variable "parts" {
type = "list"
default = [
{
content_type = "text/x-shellscript"
content = "ls"
},
{
content_type = "text/x-shellscript"
content = "echo hi"
}
]
}
data "template_cloudinit_config" "config" {
gzip = false
base64_encode = false
part = "${var.parts}"
}
output "output" {
value = "${data.template_cloudinit_config.config.rendered}"
}
https://gist.github.com/dd910b4bdb9b2cbe03850080ff218ca9
N/A
Literal list of maps should work as a parameter to a resource or data source that takes a list of maps. The example uses a data source for ease in duplication, but the same error is seen when passing to a resource, e.g. aws_db_parameter_group.parameter
The resource doesn't see each map as a valid object:
Errors:
* data.template_cloudinit_config.config: part.0: expected object, got invalid
* data.template_cloudinit_config.config: part.1: expected object, got invalid
Please list the steps required to reproduce the issue, for example:
terraform applyN/A
Any updates on this? I ask only because of the release-0.7 tag with 0.7.3 being out and no traffic on this issue 👼
For example I could this to solve the variable number of listeners for an aws_elb ...
_
This looks good
output "output" {
value = "${var.listOfListenerObjects}"
}
but
resource "aws_elb" "elb" {
provider = "aws"
.
.
listener = ["${var.listOfListenerObjects}"]
}
gives listener.0: expected object, but got string
Hitting the same issue with 0.9.1. This would be super useful!
+1
+1
+1
+1
👍
Hi all!
Thanks for reporting this, @wr0ngway. This is one of a number of quirks with more complex data structures in Terraform right now, resulting from the fact that Terraform originally didn't support such structures at all and so the current state is a pragmatic intermediate step to allow simple use-cases to be addressed. We are planning to further improve the situation around complex structures, including looking at whether we can find a way to support dynamic generation of nested configuration blocks from variables, but we're not currently actively working on implementing this since things are still in the early design phase.
Since this discussion seems to just be attracting upvotes at this point, I'm going to lock it to remove the noise for the many people who are following this issue. We'll unlock it again later when things are further along and we have more to discuss here.
Thanks again!
Hi all! Sorry for the long silence here; some outdated labeling on this issue caused me to miss it on a previous pass.
This issue is actually covering the same problem as #7034, which has now been resolved in master with the introduction of the special dynamic block type, which I showed an example of in a comment over there. This will be included in the forthcoming v0.12.0 release, so I'm going to close this out.
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
For example I could this to solve the variable number of listeners for an aws_elb ..._
_
This looks good
output "output" {
value = "${var.listOfListenerObjects}"
}
but
resource "aws_elb" "elb" {
provider = "aws"
.
.
listener = ["${var.listOfListenerObjects}"]
}
gives listener.0: expected object, but got string