Forum Discussion

klevak's avatar
klevak
Icon for Nimbostratus rankNimbostratus
May 15, 2024

Using Terraform to update / modify an existing iRule

I could be missing something obvious here.  I am attempting to use terraform to update an existing iRule (code below).  Every time I run 'apply' I get an error saying: "

The requested iRule (/Common/Load_MWservices) already exists in partition Common"

 

I am wondering what the option would be to update an existing rule?  It seems I can only create new ones?  Thanks in advance

 

 

 

variable f5_hostname {}
variable f5_username {}
variable f5_password {}

terraform {
  required_providers {
    bigip = {
      source = "F5Networks/bigip"
    }
  }
}

provider "bigip" {
  address  = var.f5_hostname
  username = var.f5_username
  password = var.f5_password
}

# Loading from a file is the preferred method
resource "bigip_ltm_irule" "rule" {
  name  = "/Common/Load_MWservices"
  irule = file("Load_MWservices")
}

2 Replies

  • You can't modify existing iRule. Delete and recreate iRule is only options. 

    irule = file("Load_MWservices")

     

  • Hey I was able to accomplish this and it was pretty simple.

    Step 1. Create a Resource block for the existing iRule

    resource "bigip_ltm_irule" "my_irule" {

    name = "/Common/existing-irule-name"

    irule = "" # Leave empty initially

    }


    Step 2. RUn the import command

    terraform import bigip_ltm_irule.my_irule /Common/existing-irule-name

    Step 3. Grab the irule contents

    terraform state show bigip_ltm_irule.my_irule



    From here you can paste this irule into the irule block that we left empty above..Im keeping all my iRule files seperated.

    Hope this helps someone.