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

mware / terraform-provider-vra7 Provider is considering the computed values as changes in the resource even though there is no update which has taken place

Open divya-goyal opened this issue 3 years ago • 6 comments

vRA 7.x version The vRA 7.6 version Terraform version The terraform version : 0.14 terraform-provider-vra7 plugin version The terraform-provider-vra7 plugin version (e.g. commit id, etc.) terraform-provide-vra7 : 3.0

Describe the bug I am using vmware / terraform-provider-vra7 version 3.0.2, facing an issue with the way terraform evaluate the difference for the newly created resource.

For example, we provide the module with the expected input to create a VM in Vshere, and successfully get the VM created as well in return we receive the extended set of variables which gets computed as output which is more then the ones which has been submitted with the request to create the VM.

Now, if the vm is not updated, and we try to submit the request again without any changes to the resource in that case we gets too many differences which impacts the day 2 operation as we didnt have those values as input.

Also, if we update the cpu count, in that case if we run terraform plan. Console displays multiple changes even though only cpu count was updated.

To Reproduce Steps to reproduce the behaviour: Terraform config files cant be uploaded due to security. but from reference perspective all the standard config has been used. for provider username, password and tenant value has been passed to the provider to create the resource in the vsphere.

After, resource gets successfully provisioned, terraform returns with the output with all the computed values and the output gets stored in the tf.state file.

Now, if we run terraform apply, the provided shows up multiple difference in console for the resource configuration even though there is no update to the resource. Only difference is the provided input and computed values after the resource provisioning is different.

  1. Terraform config file source "vra7_deployment" "vm" { count = var.destroy == true ? 0 : 1 catalog_item_name = "xxxxxxxx" businessgroup_name = "xxxxxxxxxx" wait_timeout = 60 description = format("%s Terraform build") lease_days = var.buildEnvironment == "xxxxxx" ? leaseDays : 1 lifecycle { # Ignore any lease_days (as it changes immediately!) ignore_changes = [lease_days] } resource_configuration { component_name = "vSphere__vCenter__Machine_1" cluster = 1 # One machine configuration = merge(var.minimalConfig == "true" ? local.minimal_config : {}, local.standard_config, {
    cpu = var.cpu, memory = var.memoryGB * 1024

         }
     )
    

    } }

  2. Terraform command terraform init terraform apply

  3. Wait for VM provisioning, then run below command without any module input update terraform init terraform apply

  4. Console output comes back with the lot of differences between the VM state. Even though there is no update from the user perspective.

Expected behaviour As there is no update in the resource when we run the terraform plan on an already created resource there should not be any difference for running the day operation.

if the module updates only the cpu count, then only cpu count should get displayed in the changes in console when we run terraform plan. Console should not display these many updates as only cpu count resource config got updated.

Logs Attach logs to help debug the issue logs cant be added due to security, and there is no crash.

Desktop (please complete the following information):

  • OS: Windows Server 2016

Additional context Add any other context about the problem here. We can not add the ignore resource_configuration while creating the resource, as we need to support all the day 2 operation. and need the resource_configuration for that. lifecycle { # Ignore any resource config differences and lease_days (as it changes immediately!) ignore_changes = [ resource_configuration, lease_days] }

divya-goyal avatar Apr 14 '21 02:04 divya-goyal