-
Notifications
You must be signed in to change notification settings - Fork 119
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
Problem to add pool atttachments with for_each #876
Comments
Hi @Hoonigan-013, Can you share your TF file with the for_each? |
Hi, @pgouband resource "bigip_ltm_pool" "pool" {
for_each = var.vs_creation
name = "/Part/${format("%s-%s-%s","pool","${each.value.service_name}","${each.value.pool_port}")}"
load_balancing_mode = "${each.value.pool_lb_mode}"
minimum_active_members = 1
monitors = "${each.value.pool_monitor}"
slow_ramp_time = 0
depends_on = [bigip_ltm_node.node]
}
resource "bigip_ltm_pool_attachment" "attach_node" {
for_each = var.node_creation
pool = "${bigip_ltm_pool.pool[each.key].name}"
node = "${bigip_ltm_node.node[each.key].name}:${each.value.pool_port}"
}
resource "bigip_ltm_node" "node" {
for_each = var.node_creation
name = "/Part/${each.value.node_name}"
#name = "/Part/${var.node_name}"
address = "${each.value.node_address}"
connection_limit = "0"
dynamic_ratio = "1"
monitor = "${each.value.node_monitor}"
rate_limit = "disabled" Just to explain Why I am using different for_eachs. In vs_creation there's attributes to create all pool and vs configuration and in node_creation all configuration to node creation. It was separeted because node is a string type and when I need to create more than one node with string variable inside vs_creation it is not possible create more than one node. So, the ideia is create a for each to nodes to create how many nodes I need and after it create pool attachment with the same quantity as nodes creation. For example: So, the nodes will be attached in that single pool that was created. This way, I receive errors with this each values because they belongs a var.vs_creation not var.node_creation : This correlation is being the problem for me :( |
Hi @Hoonigan-013, Thanks for sharing. |
variables.tf
variable "vs_creation" {
type = map(object({
service_name = string
vs_port = number
vs_profile = list(string)
vs_persistence = optional(list(string))
pool_lb_mode = string
pool_monitor = list(string)
pool_port = string
}))
default = {
service_name = null
vs_port = null
vs_profile = null
vs_persistence = null
pool_lb_mode = null
pool_monitor = null
pool_port = null
}
}
variable "node_creation" {
type = map(object({
node_name = string
node_address = string
node_monitor = string
}))
}
terraform.tfvars
vs_creation = {
01 = {
service_name = "test"
vs_port = 443
vs_profile = ["/Common/tcp", "/Common/http"]
vs_persistence = ["/Common/source_addr"]
pool_lb_mode = "round-robin"
pool_monitor = ["/Common/gateway_icmp"]
pool_port = "443"
}
node_creation = {
01 = {
node_name = "test.hom.si.net"
node_address = "172.172.10.249"
node_monitor = "/Common/gateway_icmp"
} I tried with different for_each because sometimes I need to add more than one node, so using only vs_creation I cannot add more than one node because node address and node name are string type. |
Hi @Hoonigan-013, In the following resource, the for_each is based on node_creation but in node_creation there is no pool_port. resource "bigip_ltm_pool_attachment" "attach_node" {
for_each = var.node_creation
pool = "${bigip_ltm_pool.pool[each.key].name}"
node = "${bigip_ltm_node.node[each.key].name}:${each.value.pool_port}"
} Here an example of solution, adding pool_port in node_creation variable. variables.tf variable "node_creation" {
type = map(object({
node_name = string
node_address = string
node_monitor = string
pool_port = string
}))
} terraform.tfvars node_creation = {
01 = {
node_name = "test.hom.si.net"
node_address = "172.172.10.249"
node_monitor = "/Common/gateway_icmp"
pool_port = "443"
}
} |
have you found a workaround in this setup? TYIA |
Hello,
I am using a different for_each in pool resources to create more than one pool with the same resource and another for_each in node to create new nodes with the same resources. So, if I try to use any of these two for_each in pool attachment I receive index error because pool is using one for_each and nodes another for_each.
Could you help me, how can I solve this issue?
Is it possible create pool attachments with for in both resources (pool and node)?
The text was updated successfully, but these errors were encountered: