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
105 stars 119 forks source link

Big-IQ bigip_bigiq_as3 resource - Provider produced inconsistent final plan #957

Open ghazalehca opened 7 months ago

ghazalehca commented 7 months ago

Environment

Summary

Build Terraform plan is producing inaccurate build plan when state is empty (first time building resource).
image Take Note of the missing as3_json attribute in the build plan above. This happens when the resource is first created.

If you disregard this and try to deploy, you will get the following error: image

Note: This does not happen in the bigip_as3 resource. Only bigip_bigiq_as3 resource. (See below the build plan from bigip_as3 resource) image

Severity: Showstopper, no work-around available.

Steps To Reproduce

After careful trouble-shooting, this occurs when there is a reference to a variable that is only “known after apply”… in this case, it’s calling an external resource (phpipam). the as3_json attribute is not getting the “(known after apply)” indicator in the plan that allows the terraform-apply to process successfully.

See attached main.tf in order to see the implementation…

resource "bigip_bigiq_as3" "tenants" {
  #This isn't really a valid AS3 json body, but it doesn't matter, this just simplifies and illustrates the problem
  as3_json         = "{ \"class\": \"AS3\", \"action\": \"deploy\", \"persist\": true, \"dummy\": ${phpipam_first_free_address.snat_ip_next_address_1["HTTPS_TENANT_1"].ip_address} }"
  bigiq_address    = var.bigiq_ip
  bigiq_user       = var.bigiq_user
  bigiq_password   = var.bigiq_pw
  bigiq_token_auth = false
}

if the as3_json argument above has an external value (from another provider), this problem arises.

You must start from an empty terraform state-file (for that resource). If you try to deploy and fail, it seems the 2nd attempt will work.

  1. Observe the following error response: image

Expected Behavior

Expected behavior is already coded correctly in the bigip_as3 resource. It's incorrect in the bigiq_bigip_as3 resource. image

Actual Behavior

It's all above. but I could reiterate.

Summary Build Terraform plan is producing inaccurate build plan when state is empty (first time building resource).
image

Note: the missing as3_json attribute in the build plan above.

If you disregard this and try to deploy, you will get the following error: image

Note: This does not happen in the bigip_as3 resource. Only bigip_bigiq_as3 resource. (See below)

image

Problem After careful trouble-shooting, this occurs when there is a reference to a variable that is only “known after apply”… in this case, it’s calling an external resource (phpipam). the as3_json attribute is not getting the “(known after apply)” indicator in the plan that allows the terraform-apply to process successfully.

See attached main.tf in order to see the implementation… You must start from an empty terraform state-file (for that resource). If you try to deploy and fail, it seems the 2nd attempt will work.

pgouband commented 7 months ago

Hi,

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