Terraform: using terraform output and count > 1

Created on 22 Oct 2015  ยท  7Comments  ยท  Source: hashicorp/terraform

I want use terraform output when provisioning multiple servers ( using count > 1 ) on openstack.

i believe it's looking for hardcoded name , and it's not working correctly. Is there any option to specify regex or any other ways ?

My config files

resource "openstack_compute_instance_v2" "test_server2" {
name = "tf-test3"
region = "${var.region}"
image_id = "${var.image_id}"
flavor_id = "${var.flavor_id}"
metadata {
this = "that"
}
key_pair = "${var.key_pair}"
security_groups = ["daas_ssh"]
count="${var.count}"
}

output "ip" {
value = "${openstack_compute_instance_v2.test_server2.access_ip_v4}"
}

Appreciate any help.

Thanks
Sriram

core documentation question

Most helpful comment

perfect works.

for reference,

resource "openstack_compute_instance_v2" "test_server2" {
name = "tf-test3"
region = "${var.region}"
image_id = "${var.image_id}"
flavor_id = "${var.flavor_id}"
metadata {
this = "that"
}
key_pair = "${var.key_pair}"
security_groups = ["daas_ssh"]
count="${var.count}"
}

output "ip" {
value = "${join(",",openstack_compute_instance_v2.test_server2.*.access_ip_v4)}"
}

All 7 comments

Someone was having a similar issue here #3362, let me know if my explanation there helps.

perfect works.

for reference,

resource "openstack_compute_instance_v2" "test_server2" {
name = "tf-test3"
region = "${var.region}"
image_id = "${var.image_id}"
flavor_id = "${var.flavor_id}"
metadata {
this = "that"
}
key_pair = "${var.key_pair}"
security_groups = ["daas_ssh"]
count="${var.count}"
}

output "ip" {
value = "${join(",",openstack_compute_instance_v2.test_server2.*.access_ip_v4)}"
}

Seems like the question is answered here, but I wonder if there's something to be added to the docs here given that two different people were tripped up by this already.

There is documentation here

Maybe adding another example along these lines would be nice.

Closing this since its been over a year and this is a working feature.

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.

Was this page helpful?
0 / 5 - 0 ratings