-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes are planned unnecessarily due to whitespace diffs when using file() function #23928
Comments
Hi @nick-doyle, Terraform Core itself treats a file loaded with A common cause of this problem is that the version control system is configured to rewrite these files to use Windows-style line endings ( However, fortunately there is a mechanism for Terraform to get a better result here: The provider itself can include a normalization rule that allows it to signal to Terraform that even though the string is not character-for-character equal, it's still "equal enough" to not need updating. On the provider development side this is called For that reason, I'm going to ask our bot to move this issue over to the Azure provider repository in the hope that the provider could be updated to include such a rule for this |
This issue has been automatically migrated to hashicorp/terraform-provider-azurerm#5500 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to hashicorp/terraform-provider-azurerm#5500. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
Bearing in mind I am not actually making any Terraform config changes at this moment in time, when I run a 'terraform plan' I expect:
Actual Behavior
'terraform plan' gives:
Note the lines which start with 'sample'. Those lines show '# whitespace change' when there have been no changes made at all.
Steps to Reproduce
This problem, whereby Terraform is unnecessarily applying changes due to perceived whitespace change, occurs when two different team members are working on two different operating systems (Unix and Windows).
terraform apply
terraform plan
and observe that no changes are detected - correctly.terraform plan
. Observe that it wants to make a change due to whitespace differences, as per output shown above.The same problem occurs if working the other way round (start with Windows, switch to Unix/Mac).
Additional Context
The problem appears to be down to the way the Unix/Windows versions of Terraform each handle whitespace slightly differently when the file() function runs and a 'jsonencode' statement is produced. It happens for any resource type.
This unnecessary output clutters everything when reviewing changes and results in many more 'apply' commands being run by team members and by CI.
References
The text was updated successfully, but these errors were encountered: