Skip to content

avi_applicationpersistenceprofile of type PERSISTENCE_TYPE_HTTP_COOKIE always detects changes #650

@jakauppila

Description

@jakauppila

Describe the bug

When configuring an Application Persistence Profile of type PERSISTENCE_TYPE_HTTP_COOKIE with the supplied configuration, Terraform always detects a change as we are not generating the encryption key upon creation of the resource, we are leaving that optional parameter for AVI to create.

Reproduction steps

  1. Configure an avi_applicationpersistenceprofile of type PERSISTENCE_TYPE_HTTP_COOKIE with the necessary http_cookie_persistence_profile block defined with some options defined
  2. Run Terraform Apply
  3. Run Terraform Plan or Apply again without making changes to the Terraform configuration
  4. Observe that Terraform detects a change due to the encryption key being generated by AVI and Terraform wanting to remove it as it is not explicitly defined within the HCL

Reproduction Terraform HCL:

terraform {
  required_providers {
    avi = {
      source  = "vmware/avi"
      version = "30.2.2"
    }
  }
}

provider "avi" {
  avi_controller = "avi-controller.contoso.com"
  avi_tenant     = "admin"

  avi_version    = "30.2.2"
}

data "avi_cloud" "cloud" {
  name = "mycloud"
}

resource "avi_applicationpersistenceprofile" "persistence" {
  name = "persistence"
  persistence_type = "PERSISTENCE_TYPE_HTTP_COOKIE"

  server_hm_down_recovery = "HM_DOWN_PICK_NEW_SERVER"

  http_cookie_persistence_profile {
    always_send_cookie   = false
    cookie_name          = "cookie"
    http_only            = false
    is_persistent_cookie = false
  }
}

Terraform apply output:

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:

  # avi_applicationpersistenceprofile.persistence will be updated in-place
  ~ resource "avi_applicationpersistenceprofile" "persistence" {
        id                      = "https://avlb-controller.contoso.com/api/applicationpersistenceprofile/applicationpersistenceprofile-55adf7d5-7cfd-4abd-b968-9a3f85c6f1b3"
        name                    = "persistence"
        # (5 unchanged attributes hidden)

      - http_cookie_persistence_profile {
          - always_send_cookie   = "false" -> null
          - cookie_name          = "cookie" -> null
          - http_only            = "false" -> null
          - is_persistent_cookie = "false" -> null
            # (2 unchanged attributes hidden)

          - key {
              - aes_key  = "xuRFtGI5F0TYuUZwNmpluRted6HuFMPqibG3uKFlccA=" -> null
              - name     = "fc40c045-fae1-450f-854a-6622918a634c" -> null
                # (1 unchanged attribute hidden)
            }
        }
      + http_cookie_persistence_profile {
          + always_send_cookie   = "false"
          + cookie_name          = "cookie"
          + encryption_key       = (known after apply)
          + http_only            = "false"
          + is_persistent_cookie = "false"
          + timeout              = (known after apply)
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Expected behavior

No changes should be detected on subsequent Terraform Plan/Apply executions.

Additional context

Related to #619 and #621 among others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions