Open RavinderReddyF5 opened 4 years ago
Comment by dannyk81 Monday Jun 10, 2019 at 15:06 GMT
if you have pre-existing resources that were not created by terraform on the managed device, the correct way to reconcile it is to import these resources into terraform.
Comment by spirrello Thursday Jul 11, 2019 at 16:18 GMT
@dannyk81 Do you have an example of how to do this with an F5 resource?
Comment by DarthVader2409 Thursday Jul 11, 2019 at 17:03 GMT
All BIGIP resources can be imported but terraform can import only one resource at a time.
Usage: terraform import [options] ADDR ID ADDR- address to import the resource to. ID- resource specific ID to identify the resource being imported
To import a resource, first write a resource block for it in your configuration, establishing the name by which it will be known to Terraform: resource "bigip_ltm_monitor" "monitor" { name = "/Common/terraform_monitor . . . . . } Now run terraform init and terraform import to attach an existing instance to this resource configuration: Example: terraform import bigip_ltm_monitor.monitor /Common/https_mon
This command locates the bigip ltm monitor with ID /Common/https_mon and attaches its existing settings, to the name bigip_ltm_monitor.monitor in the Terraform state
The ID provided for the import is created when the resource to be imported runs "terraform apply". Then when you do "terraform show" command you can view the ids of all created resources. Once the import is successful, look for terraform.tfstate file in your directory to verify the import.
Issue by spirrello Monday Jun 10, 2019 at 15:03 GMT Originally opened as https://github.com/terraform-providers/terraform-provider-bigip/issues/115
We have an issue when the pool and VIPs already exist on the F5 load balancer, Terraform always fails. I've tried refreshing but the only way to reconcile this is to delete the pools or VIPs on the F5 and then execute the terraform script.
Is there a better way to work around this?
Script
resource "bigip_ltm_pool" "pool" {
name = "${var.partition}${var.pool}" load_balancing_mode = "round-robin" monitors = ["tcp_half_open"] allow_snat = "yes" allow_nat = "yes" }
resource "bigip_ltm_pool_attachment" "attach_node" { count = "${length(var.node_names)}"
pool = "${var.partition}${var.pool}"
node = "${var.partition}${element(var.node_names, count.index)}:9443"
depends_on = ["bigip_ltm_pool.pool"] }
resource "bigip_ltm_virtual_server" "https" {
name = "${var.partition}${var.vip_name}" destination = "${var.virtual_ip}" port = "${var.vip_port}" pool = "${var.partition}${var.pool}" profiles = "${var.profiles}" source_address_translation = "${var.source_address_translation}" translate_port = "${var.translate_port}" vlans_enabled = "${var.vlans_enabled}" vlans = ["${var.vlan}"]
depends_on = ["bigip_ltm_pool.pool"] }
ERROR 5 error(s) occurred:
module.app01-c4.module.app01-c4.bigip_ltm_pool_attachment.attach_node[1]: 1 error(s) occurred:
bigip_ltm_pool_attachment.attach_node.1: Failure adding node /Common/AT4D-LVKC4N02-10.155.28.152:9443 to pool /Common/APP01-C4: 01020066:3: The requested Pool Member (/Common/APP01-C4 /Common/AT4D-LVKC4N02-10.155.28.152 9443) already exists in partition Common.
module.app01-c4.module.app01-c4.bigip_ltm_virtual_server.https: 1 error(s) occurred:
bigip_ltm_virtual_server.https: 01020066:3: The requested Virtual Server (/Common/APP01-C4.AT4D.ACME.COM) already exists in partition Common.
module.app01-c4.module.app01-c4.bigip_ltm_pool_attachment.attach_node[0]: 1 error(s) occurred:
bigip_ltm_pool_attachment.attach_node.0: Failure adding node /Common/AT4D-LVKC4N01-10.155.28.151:9443 to pool /Common/APP01-C4: 01020066:3: The requested Pool Member (/Common/APP01-C4 /Common/AT4D-LVKC4N01-10.155.28.151 9443) already exists in partition Common.
module.mqgateway-c1.module.mqgateway-c1.bigip_ltm_virtual_server.https: 1 error(s) occurred:
bigip_ltm_virtual_server.https: 01020066:3: The requested Virtual Server (/Common/AT4D-VPMQG-443) already exists in partition Common.
module.app01-c4.module.app01-c4.bigip_ltm_pool_attachment.attach_node[2]: 1 error(s) occurred:
bigip_ltm_pool_attachment.attach_node.2: Failure adding node /Common/AT4D-LVKC4N03-10.155.28.153:9443 to pool /Common/APP01-C4: 01020066:3: The requested Pool Member (/Common/APP01-C4 /Common/AT4D-LVKC4N03-10.155.28.153 9443) already exists in partition Common.