v0.7.3
resource "aws_network_interface" "database-lan2" {
subnet_id = "${aws_subnet.private-subnet.id}"
private_ips = ["10.0.1.5${count.index}"]
security_groups = ["${aws_security_group.oracle_elb.id}"]
attachment {
instance = "${element(aws_instance.database.*.id, count.index)}"
device_index = 1
}
count = "${var.database_count}"
}
resource "null_resource" "dblan-collect" {
provisioner "local-exec" {
command = "echo ${format("db%03d-priv", count.index +1)} ${formatlist("%s", aws_network_interface.database-lan2.*.private_ips, count.index)} > output/${format("priv_db%03d.txt", count.index +1)}"
}
count = "${var.database_count}"
depends_on = ["aws_network_interface.database-lan2"]
}
I have tried using formatlist
${formatlist("%s", aws_network_interface.database-lan2.*.private_ips, count.index)}
which fails with
* At column 1, line 1: output of an HIL expression must be a string, or a single list (argument 4 is TypeList) in:
Also tried element
${element(aws_network_interface.database-lan2.*.private_ips, count.index)}
which fails with
* element: element() may only be used with flat lists, this list contains elements of type list in:
everything sets up correctly but fails during with the error while trying to output the private_ips from the aws_network_interface resource.
this is how I resolved that same error with my elasticsearch domain resource
in variables
ip's below changed to protect the guilty.
variable "source_ips" {
type = "list"
default = ["8.8.8.8/32","4.4.4.4/32"]
}
access_policies = <<CONFIG
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "es:*",
"Principal": "*",
"Effect": "Allow",
"Condition": {
"IpAddress": { "aws:SourceIp": ["${join("\",\"", var.source_ips)}"] }
}
}
]
}
CONFIG
Works, as if by magic! Thanks!
I'm impressed by this hack!! :D It's really bad that terraform has got problems with supporting map of lists...
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
this is how I resolved that same error with my elasticsearch domain resource
in variables
ip's below changed to protect the guilty.