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

lifecycle ignore_changes is not working as expected for avi_virtualservice resource

Open kiranjagtap41 opened this issue 1 year ago • 0 comments

Describe the bug

lifecycle ignore_changes is not working as expected for avi_virtualservice resource. In my case i have two datascripts attached to VS and if i add ignore lifecycle for datascript is isn't ignoring or validating if someone other tool had changed datascripts on AVI directly. If i got do API call against AVI to change Data script allocation within VS , next terraform apply will change it to state if was per last terraform apply.

Below is the code i am testing this with.

data "avi_sslprofile" "pp_strong" {

name = "pp_strong"

}

data "avi_vsdatascriptset" "healthcheck_disable" {

name = "healthcheck_disable"

}

data "avi_vsdatascriptset" "healthcheck_enable" {

name = "healthcheck_enable"

}

data "avi_vsdatascriptset" "ds_geo_ip" {

name = "ds_geo_ip"

}

resource "avi_virtualservice" "test" {

name = "test"

vsvip_ref = avi_vsvip.test1.id

enabled = true

vs_datascripts {

index = 1

vs_datascript_set_ref = data.avi_vsdatascriptset.healthcheck_disable.id

}

vs_datascripts {

index = 2

vs_datascript_set_ref = data.avi_vsdatascriptset.ds_geo_ip.id

} lifecycle{ ignore_changes =[ vs_datascripts ] }

services {

port = 80

port_range_end = 80

}

}

Reproduction steps

  1. Create VS with datascript attached to it and apply config via terraform.
  2. Change Datascript on virtual service either via API calls or via GUI.
  3. Add lifecycle ignore to terraform code and perform terraform apply. You will not see terraform making any changes to Datascript in plan or apply command however when apply it complete you will see Datascripts are reverted back to what it was in Terraform git code. ...

Expected behavior

Expecting that if any changes were done on datascripts side via direct API's or console terraform should ignore them as we have ignore lifecycle configuration added.

Additional context

No response

kiranjagtap41 avatar Jun 15 '23 13:06 kiranjagtap41