Open ratsalad21 opened 4 months ago
Hi @ratsalad21,
I tested the following with success:
import {
to = bigip_ltm_pool_attachment.attach_node_mypool
id = "{ \"pool\": \"/Common/my-pool2\", \"node\": \"/Common/server2:80\" }"
}
$ terraform plan -generate-config-out=generated.tf
bigip_ltm_pool_attachment.attach_node_mypool: Preparing import... [id={ "pool": "/Common/my-pool2", "node": "/Common/server2:80" }]
bigip_ltm_pool_attachment.attach_node_mypool: Refreshing state... [id=/Common/my-pool2-/Common/server2:80]
Terraform used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# bigip_ltm_pool_attachment.attach_node_mypool will be updated in-place
# (imported from "{ "pool": "/Common/my-pool2", "node": "/Common/server2:80" }")
~ resource "bigip_ltm_pool_attachment" "attach_node_mypool" {
id = "/Common/my-pool2-/Common/server2:80"
node = "/Common/server2:80"
pool = "/Common/my-pool2"
+ state = "enabled"
}
Plan: 1 to import, 0 to add, 1 to change, 0 to destroy.
╷
│ Warning: Config generation is experimental
│
│ Generating configuration during import is currently experimental, and the
│ generated configuration format may change in future versions.
╵
───────────────────────────────────────────────────────────────────────────────
Terraform has generated configuration and written it to generated.tf. Please
review the configuration and edit it as necessary before adding it to version
control.
Note: You didn't use the -out option to save this plan, so Terraform can't
guarantee to take exactly these actions if you run "terraform apply" now.
I'm not the OP, but can confirmed this worked for me.
Environment
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.