Closed FrenchBen closed 6 years ago
I have not came across any solution for this. Pls check the available builtin functions of terraform at https://www.terraform.io/docs/configuration/interpolation.html#built-in-functions
Alternatively we can come up with a resource to attach the server instances to lbaas. Through which we can support the dynamic association.. We will look in to this
@Praveengostu In your terraform deployments, how do you attach these dynamic instances then?
Could we remove the complexity of the server_instance
structure, and use something like a list? How often is the "weight" used? (seems like the only reason for the complex variable)
For comparison, see the simplicity of associating an instance with an ELB within the AWS terraform module: https://www.terraform.io/docs/providers/aws/r/elb.html
@FrenchBen as mentioned we will look in to the lbaas resource on removing the complexity to attach dynamic instances. Thank you
To achieve the dynamic association of server intances, One of the option is to remove the server instaces from lbaas and create a seperate resource for attaching the server instance. Example:
resource "ibm_compute_vm_instance" "vm_instances" {
count = "2"
....
}
resource "ibm_lbaas" "lbaas" {
name = "terraformLB"
description = "delete this"
subnets = [1511875]
protocols = [{
frontend_protocol = "HTTPS"
frontend_port = 443
backend_protocol = "HTTP"
backend_port = 80
load_balancing_method = "round_robin"
tls_certificate_id = 11670
},
{
frontend_protocol = "HTTP"
frontend_port = 80
backend_protocol = "HTTP"
backend_port = 80
load_balancing_method = "round_robin"
},
]
}
resource "ibm_lbaas_server_instance_attachment" "server_attach" {
count = 2
private_ip_address = "${element(ibm_compute_vm_instance.vm_instances.*.ipv4_address_private,count.index)}"
lbaas_id = "${ibm_lbaas.lbaas.id}
}
With this we can dynamically attach the server instances to lbaas. Let us know if this helps.
@Praveengostu when do you think this can go into the plugin/release?
@FrenchBen The fix is in progress and I will get back to you on the availability of release with fix.
@FrenchBen The fix is available in the latest build located at https://github.com/IBM-Cloud/terraform-provider-ibm/releases/tag/v0.9.1
Terraform Version
0.11.3
Affected Resource(s)
Terraform Configuration Files
Taken from: https://ibm-cloud.github.io/tf-ibm-docs/v0.8.0/r/lbaas.html
Expected Behavior
Use the dynamically provided VM information, to create an LB that supports all instances
Actual Behavior
The above example (seen in the documentation), provides a
count
for theibm_compute_vm_instance
in order to populate a certain number of VMs pretty easily, yet is incapable of dynamically allocating those VM IPs to the load balancer. If I was to switch thecount = "2"
to acount = "3"
, I would manually have to update the load balancer definition to be:Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
terraform apply
(your new VM isn't part of the LB, unless you update the actual code