terraform-provider-bigip
                                
                                
                                
                                    terraform-provider-bigip copied to clipboard
                            
                            
                            
                        Facing API error while trying to create iRule using terraform provider
We are facing below API related errors while trying to create iRule using terraform provider. please help to resolve issues.
API Error observed: Error creating iRule /Common/APIGW-Stage-iRule.tcl: HTTP 400 :: {"code":400,"message":""{" unknown property","errorStack":[],"apiError":26214401}
Error creating iRule /Common/F5WAF.tcl: HTTP 400 :: {"code":400,"message":""{" unknown property","errorStack":[],"apiError":26214401}
Error creating iRule /Common/MCCAcademy.tcl: HTTP 400 :: {"code":400,"message":""{" unknown property","errorStack":[],"apiError":26214401}
Error creating iRule /Common/MCCUP-Stage-iRule.tcl: HTTP 400 :: {"code":400,"message":""{" unknown property","errorStack":[],"apiError":26214401}
Error creating iRule /Common/Netsparker-workaround.tcl: HTTP 400 :: {"code":400,"message":""{" unknown property","errorStack":[],"apiError":26214401}
Error creating iRule /Common/Pardot-Sandbox-iRule.tcl: HTTP 400 :: {"code":400,"message":""{" unknown property","errorStack":[],"apiError":26214401}
Error creating iRule /Common/Salesforce-Sandbox-iRule: HTTP 400 :: {"code":400,"message":""{" unknown property","errorStack":[],"apiError":26214401}
Hi @rakotkar0608,
Could you share your Terraform files?
resource "bigip_ltm_irule" "irule" {
for_each = fileset("local-traffic-mgmt/irules", "*.tcl")
name  = "/Common/${trimsuffix(each.value, ".tcl")}"
irule = file("local-traffic-mgmt/irules/${each.value}")
depends_on = [bigip_ltm_profile_http.http-aptplatform]
}
Above is the code. Please check it.
We are waiting for your responce.
Hi @rakotkar0608,
I tested the following with version 1.15.1 of BIG-IP provider.
$ more main.tf
resource "bigip_ltm_irule" "irule" {
	for_each = fileset("irules", "*.tcl")
		name = "/Common/${trimsuffix(each.value, ".tcl")}"
		irule = file("irules/${each.value}")
}
$ more irules/myirule.tcl 
when HTTP_REQUEST {
  if { [string tolower [HTTP::header value Upgrade]] equals "websocket" } {
    HTTP::disable
#    ASM::disable
    log local0. "[IP::client_addr] - Connection upgraded to websocket protocol. 
Disabling ASM-checks and HTTP protocol. Traffic is treated as L4 TCP stream."
  } else {
    HTTP::enable
#    ASM::enable
    log local0. "[IP::client_addr] - Regular HTTP request. ASM-checks and HTTP p
rotocol enabled. Traffic is deep-inspected at L7."
  }
}
$ terraform plan -out test-irule
Terraform used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
  + create
Terraform will perform the following actions:
  # bigip_ltm_irule.irule["myirule.tcl"] will be created
  + resource "bigip_ltm_irule" "irule" {
      + id    = (known after apply)
      + irule = <<-EOT
            when HTTP_REQUEST {
            
              if { [string tolower [HTTP::header value Upgrade]] equals "websocket" } {
                HTTP::disable
            #    ASM::disable
                log local0. "[IP::client_addr] - Connection upgraded to websocket protocol. Disabling ASM-checks and HTTP protocol. Traffic is treated as L4 TCP stream."
              } else {
                HTTP::enable
            #    ASM::enable
                log local0. "[IP::client_addr] - Regular HTTP request. ASM-checks and HTTP protocol enabled. Traffic is deep-inspected at L7."
              }
            }
        EOT
      + name  = "/Common/myirule"
    }
Plan: 1 to add, 0 to change, 0 to destroy.
───────────────────────────────────────────────────────────────────────────────
Saved the plan to: test-irule
To perform exactly these actions, run the following command to apply:
    terraform apply "test-irule"
$ terraform apply "test-irule"
bigip_ltm_irule.irule["myirule.tcl"]: Creating...
bigip_ltm_irule.irule["myirule.tcl"]: Creation complete after 1s [id=/Common/myirule]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Are you using the latest version of BIG-IP provider?
The error maybe is related to the irule. Could you share the irules?
We are not facing this issue now. You can close it.