Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to using template_file for building dynamic members #4252

Closed
KangyiZengVizio opened this issue Dec 10, 2015 · 8 comments
Closed

Failed to using template_file for building dynamic members #4252

KangyiZengVizio opened this issue Dec 10, 2015 · 8 comments
Labels

Comments

@KangyiZengVizio
Copy link

Guys, we all know that the openstack_lb_pool_v1 can not dynamic creating member depends on the number of instance, so I try to use template file to build the member.
Here is my code

resource "openstack_lb_pool_v1" "pool_1" {
count="${var.count}"
name="test_testing_lb_pool"
 region = "${lookup(var.defaults, "region")}"
protocol="HTTP"
subnet_id="${lookup(var.defaults,"lbaas_subnet")}"
lb_method = "ROUND_ROBIN"

  member {"${element(template_file.members.*.rendered,count.index)}"}
}

resource "template_file" "members" {
count ="${var.count}"
template = "${file("templates/members.tpl")}"

vars {
region = "${lookup(var.defaults, "region")}"
address="${element(openstack_compute_instance_v2.compute_worker.*.access_ip_v4, count.index)}"
port = 80
admin_state_up = "true"
}
}

but when I run terraform plan, the output is like

←[31mErrors:
←[0m←[0m
←[31m * openstack_lb_pool_v1.pool_1 #0: "member.0.address": required field is not set←[0m←[0m
←[31m * openstack_lb_pool_v1.pool_1 #0: "member.0.port": required field is not set←[0m←[0m
←[31m * openstack_lb_pool_v1.pool_1 #0: "member.0.admin_state_up": required field is not set←[0m←[0m
←[31m * openstack_lb_pool_v1.pool_1 #1: "member.0.address": required field is not set←[0m←[0m
←[31m * openstack_lb_pool_v1.pool_1 #1: "member.0.port": required field is not set←[0m←[0m
←[31m * openstack_lb_pool_v1.pool_1 #1: "member.0.admin_state_up": required field is not set←[0m←[0m

Any ideas?

@jen20
Copy link
Contributor

jen20 commented Dec 16, 2015

Hi @sifizeng. I think the issue here is that the template is producing a string, but the load balancer wants a structure. I don't think it will be a suitable solution to use templates here. Is there a known issue you are referring to with no being able to refer to a resource with a count in the load balancer configuration? This seems like the underlying issue to fix there.

@jtopjian
Copy link
Contributor

@jen20 ah, I think @sifizeng is referring to #3197. This is something I'll be working on shortly.

@KangyiZengVizio
Copy link
Author

Hi @jtopjian I saw your comment in #3197 That`s why I thought I should use template_file to build a thing like your rough example shows.

@KangyiZengVizio
Copy link
Author

@jen20 you are right. seems like template_file only can be injected to the string.

@jtopjian
Copy link
Contributor

@sifizeng Check out #4359 - it has a draft of the openstack_lb_member_v1 resource. 😄

@jtopjian
Copy link
Contributor

@sifizeng Would you consider this issue "resolved"?

@catsby
Copy link
Member

catsby commented Jan 7, 2016

Hey all – I'm going to go ahead and close this issue for now. Please let me know if there's more work required here.

Thanks!

@catsby catsby closed this as completed Jan 7, 2016
@ghost
Copy link

ghost commented Apr 29, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants