terraform-provider-bigip icon indicating copy to clipboard operation
terraform-provider-bigip copied to clipboard

Facing API error while trying to create iRule using terraform provider

Open rakotkar0608 opened this issue 3 years ago • 1 comments

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}

rakotkar0608 avatar Aug 17 '22 06:08 rakotkar0608

Hi @rakotkar0608,

Could you share your Terraform files?

pgouband avatar Aug 17 '22 15:08 pgouband

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.

rakotkar0608 avatar Sep 02 '22 09:09 rakotkar0608

We are waiting for your responce.

rakotkar0608 avatar Sep 13 '22 08:09 rakotkar0608

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?

pgouband avatar Sep 13 '22 08:09 pgouband

We are not facing this issue now. You can close it.

rakotkar0608 avatar Oct 20 '22 17:10 rakotkar0608