Closed busser closed 1 year ago
@qprichard
The rules could be passed to tfautomv with a new -ignore
flag:
tfautomv -ignore='whistespace:^azurerm_:^xml_content$'
The -ignore
flag could be added more than once to specify multiple rules.
This flag's value's syntax needs to be clearly defined. I think we can make it simpler by dropping support for patterns entirely:
tfautomv -ignore="whistespace:azurerm_api_management_api_policy:xml_content"
The syntax is therefore:
<EFFECT>:<RESOURCE TYPE>:<FIELD NAME>
For nested fields, .
can separate parent fields names from child field names:
<EFFECT>:<RESOURCE TYPE>:parent_obj.child_field
<EFFECT>:<RESOURCE TYPE>:parent_list.0
Quick update on this.
I have made progress on the feature itself, it seems to work correctly at this point.
However there is still work to be done for automatic testing of this feature, especially in our end-to-end tests, that actually run Terraform code.
Currently we only use the random
provider in our tests. This is convenient because there is no external dependency on a cloud provider and Terraform's state can be discarded after each test; no need for cleanup.
However I have not been able to create a test case with the random
provider where ignoring a field is necessary to make the right move and where, once the move is made, Terraform plans no changes.
I see two options here: use a provider that allows for such a use case, or write tests that do not expect an empty plan as a result of running tfautomv.
The first option is closest to the reason behind this new feature: different values can be functionally equivalent for some providers. However depending on an external cloud provider for testing is a major decision.
The second option requires refactoring our end-to-end test suite. I think this would be useful for testing other tfautomv behavior, not just this feature.
I plan on starting with the second option. If we decide to explore the first option, then we can think of how to do it without adding an external dependency to our tests.
Implemented in PR #16. Will close this issue after next release.
Release v0.4 adds this feature. Closing issue.
Certain resources have differences between a field's value in the Terraform code and in Terraform's state. It would be useful to ignore some of these differences.
For example, the
azurerm_api_management_api_policy
resource has anxml_content
field containing an XML string. Differences in whitespace between the field's value in the Terraform code and its value in Terraform's state are ignored by theazurerm
provider but not by tfautomv.I think it is best if tfautomv does not implement provider-specific rules for comparing resources. However, such rules can be useful. A rule system could help here. For instance, imagine this rule:
For resources with a type that matches the pattern `^azurerm
, ignore differences in whitespace in fields that match the pattern
^xmlcontent$`.If this rule could be provided to tfautomv as configuration, then users could choose to relax tfautomv's matching logic in certain cases.