Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

[WIP] Suppress diff for configuration items in case they are not set #66

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

marratj
Copy link

@marratj marratj commented Apr 30, 2020

When there is a Deployment with resource configurations for VMs that contain more or different custom properties within the configuration map, each time when terraform plan is run, there is a diff produced that completely removes the configuration block within resource_configuration and adds a new one with only the values provided in the vra7_deployment TF resource.

This seems to be because resource_configuration is a TypeSet in the Resource Schema.

That means, each time the hash calculated from the settings in the state is not identical to the one in the resource config, Terraform treats it as a different resource_configuration and wants to remove the existing block from the state and put in only the values in the config.

For this, I propose to change this to TypeList. However, this would depend on the vRA7 API returning the content[] in the ResourceView response always in the same order (which I'm not 100 % sure of right now).

After changing the Type to List, we also add a DiffSuppressFunc to the configuration Element that checks if a custom property from the state needs to be included in the diff.

If it set in the state, but NOT in the resource config, we ignore the diff. This is because often there are quite a lot of custom properties returned for a VM that are set on vRA side and are not of interest to the resource configuration in the first place.

Aims to fix #56

@ghost ghost added the size/XS label Apr 30, 2020
@marratj marratj changed the title Suppress diff for configuration items in case they are not set [WIP] Suppress diff for configuration items in case they are not set Apr 30, 2020
@marratj
Copy link
Author

marratj commented May 4, 2020

One thing I currently have in the DiffSuppressFunc is that it will ignore any custom properties from vRA/the state file that are not explicitly set in the resource_configuration.

However, that would mean for certain configurations where one would want to intentionally change a custom property from a set value to an empty value that this would also not produce a diff and therefore not trigger a change.

Any ideas on how to handle those cases?

@marratj
Copy link
Author

marratj commented May 6, 2020

@Prativa20 any thoughts on this?

Signed-off-by: Marcel Juhnke <marcel.juhnke@gfk.com>
@marratj marratj force-pushed the marratj-suppress-diff-for-resource-configuration branch from ebe9ec2 to cedb1fe Compare May 8, 2020 13:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

terraform apply always results in change despite not change to .tf
1 participant