RavinderReddyF5 / terraform-provider-bigip-version0.12

Terraform resources that can configure F5 BIGIP products
Mozilla Public License 2.0
0 stars 0 forks source link

[CLOSED] Terraform BIG IP module out of sync #146

Open RavinderReddyF5 opened 4 years ago

RavinderReddyF5 commented 4 years ago

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:

RavinderReddyF5 commented 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.

https://www.terraform.io/docs/import/

RavinderReddyF5 commented 4 years ago

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?

RavinderReddyF5 commented 4 years ago

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.