F5Networks / terraform-provider-bigip

Terraform resources that can configure F5 BIG-IP products
https://registry.terraform.io/providers/F5Networks/bigip/latest/docs
Mozilla Public License 2.0
102 stars 117 forks source link

`requestlog_template` is added to the state as `responselog_template` #955

Closed marcsauter closed 3 weeks ago

marcsauter commented 3 months ago

https://github.com/F5Networks/terraform-provider-bigip/blob/1014351a85dec1abf9ea69545cac0a2e89ddb9e0/bigip/resource_bigip_ltm_profile_request_log.go#L265

pgouband commented 3 months ago

Hi @marcsauter

Can you give more information about your request?

amolari commented 2 months ago

hello @pgouband Marc is working at my customer. They observed the following issue in the module bigip_ltm_request_log_profile: 1) TF config is

resource "bigip_ltm_request_log_profile" "tf_access_log_sec" {
  name                = "/Common/tf-access-log-sec"
  defaults_from       = bigip_ltm_request_log_profile.tf_request_log_pf.name
  request_logging     = "enabled"
  requestlog_template = "<134> $${TIME_MSECS} $${TIME_OFFSET} bigip_host=$${BIGIP_HOSTNAME} type=request"
  response_logging    = "enabled"
  responselog_template = "<134> $${TIME_MSECS} $${TIME_OFFSET} bigip_host=$${BIGIP_HOSTNAME} type=response"
}

2) After TF apply, the configuration is correct on the BIG-IP:

ltm profile request-log tf-access-log-sec {
    app-service none
    defaults-from tf-request-log-pf
    request-log-template "<134> ${TIME_MSECS} ${TIME_OFFSET} bigip_host=${BIGIP_HOSTNAME} type=request"
    request-logging enabled
    response-log-template "<134> ${TIME_MSECS} ${TIME_OFFSET} bigip_host=${BIGIP_HOSTNAME} type=response"
    response-logging enabled
}

3) however, in the TF state (because of the error in provider code mentioned above by Marc), we do see:

$ terraform state show bigip_ltm_request_log_profile.tf_access_log_sec
2024-04-11T13:38:28.958+0200 [INFO]  provider: configuring client automatic mTLS
2024-04-11T13:38:28.998+0200 [INFO]  provider.terraform-provider-bigip_v1.22.0: configuring server automatic mTLS: timestamp=2024-04-11T13:38:28.998+0200
# bigip_ltm_request_log_profile.tf_access_log_sec:
resource "bigip_ltm_request_log_profile" "tf_access_log_sec" {
    defaults_from        = "/Common/tf-request-log-pf"
    id                   = "/Common/tf-access-log-sec"
    name                 = "/Common/tf-access-log-sec"
    request_logging      = "enabled"
    requestlog_template  = "<134> ${TIME_MSECS} ${TIME_OFFSET} bigip_host=${BIGIP_HOSTNAME} type=request"
    response_logging     = "enabled"
    responselog_template = "<134> ${TIME_MSECS} ${TIME_OFFSET} bigip_host=${BIGIP_HOSTNAME} type=request"
}

==> responselog_template = requestlo_template

4) Result: TF sees a config drift and re-applied the config everytime:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # bigip_ltm_request_log_profile.tf_access_log_sec will be updated in-place
  ~ resource "bigip_ltm_request_log_profile" "tf_access_log_sec" {
        id                   = "/Common/tf-access-log-sec"
        name                 = "/Common/tf-access-log-sec"
      ~ responselog_template = "<134> ${TIME_MSECS} ${TIME_OFFSET} bigip_host=${BIGIP_HOSTNAME} type=request" -> "<134> ${TIME_MSECS} ${TIME_OFFSET} bigip_host=${BIGIP_HOSTNAME} type=response"
        # (4 unchanged attributes hidden)
    }

Please fix this issue, thank you.

amolari commented 2 months ago

I guess this issue is the same as this one #950

pgouband commented 2 months ago

Hi,

Thanks for reporting. Added to the backlog and internal tracking ID for this request is: INFRAANO-1539.