terraform-provider-bigip icon indicating copy to clipboard operation
terraform-provider-bigip copied to clipboard

Error when attempting to use Terraform Import block to import "bigip_ltm_pool_attachment"

Open ratsalad21 opened this issue 1 year ago • 1 comments

Environment

  • TMOS/Bigip Version: BIG-IP 17.1.0.3 Build 0.75.4 Engineering Hotfix
  • Terraform Version: 1.9.1
  • Terraform bigip provider Version: 1.22.2

Summary

I am attempting to import an existing bigip_ltm_pool_attachment. The pool and attached node already exist in the environment. I am using a terraform import block. When I run a terraform plan, I recieve the following message:

│ Error: Incorrect value type │ │ on main.tf line 107, in import: │ 107: id = { "pool": "/Common/service.test.com_8065_pool", "node": "/common/node01.test.com:8065" } │ │ Invalid expression value: string required. ╵ ╷ │ Error: Invalid import id argument │ │ on main.tf line 107, in import: │ 107: id = { "pool": "/Common/service.test.com_8065_pool", "node": "/common/node01.test.com:8065" } │ │ The import block "id" argument depends on resource attributes that cannot be determined until apply, so Terraform cannot plan to import this resource.

Steps To Reproduce

Steps to reproduce the behavior:

This is the terraform config I am using when I recieve the above error:

locals { keys = var.node_name values = var.node_state node_map = zipmap(local.keys, local.values) }

output "node_map" { description = "Mapping of Hostname/IPs for F5 nodes" value = local.node_map }

Import Node(s)

import { for_each = local.node_map to = bigip_ltm_node.nodes[each.key] id = "/Common/${each.key}.${var.domain}" }

Create Node(s)

resource "bigip_ltm_node" "nodes" { for_each = local.node_map name = "/Common/${each.key}.${var.domain}" address = "${each.key}.${var.domain}" state = each.value monitor = "default" description = "Managed by Terraform" }

Import Attach node(s) to pool

import { for_each = bigip_ltm_node.nodes to = bigip_ltm_pool_attachment.attach_node_8065 id = { "pool": bigip_ltm_pool.service_8065.name, "node": "${bigip_ltm_node.nodes[each.value.name]}:8065" } }

Attach node(s) to pool

resource "bigip_ltm_pool_attachment" "attach_node_8065" { for_each = bigip_ltm_node.nodes pool = bigip_ltm_pool.service_8065.name node = "${bigip_ltm_node.nodes[each.value.name]}:8065"

depends_on = [ bigip_ltm_pool.service_8065 ] }

Expected Behavior

When running terraform plan, I expect the bigip_ltm_pool_attachement to be imported.

Actual Behavior

│ Error: Incorrect value type │ │ on main.tf line 107, in import: │ 107: id = { "pool": "/Common/service.test.com_8065_pool", "node": "/common/node01.test.com:8065" } │ │ Invalid expression value: string required. ╵ ╷ │ Error: Invalid import id argument │ │ on main.tf line 107, in import: │ 107: id = { "pool": "/Common/service.test.com_8065_pool", "node": "/common/node01.test.com:8065" } │ │ The import block "id" argument depends on resource attributes that cannot be determined until apply, so Terraform cannot plan to import this resource.

ratsalad21 avatar Jul 09 '24 14:07 ratsalad21