hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
622 stars 453 forks source link

VM annotation as heredoc triggers resource update across applies when unmodified #2252

Open arcticgeek opened 3 months ago

arcticgeek commented 3 months ago

Community Guidelines

Terraform

1.9.5

Terraform Provider

hashicorp/vsphere 2.8.3

VMware vSphere

7.0.3 build 22357613

Description

When a multi-line virtual machine annotation is specified using a heredoc (using <<-EOT) it is correctly saved through vSphere provider, but subsequent applies of the same unmodified annotation shows changes are detected. The changes detected are apparently phantom, showing per-line changes from -value to +value in plan/apply output with the line content shown is clearly unmodified.

When the multi-line annotation is specified as a single string with inline C-style escaped line-endings (e.g.: "my multi-line\nawesome\n\nannotation"), the problem does not exist. The multi-line annotation is saved and appears as intended, and subsequent plan/apply invocations detect no changes.

Affected Resources or Data Sources

Terraform Configuration

Example annotation demonstrating issue, lines are TAB-prefixed:

annotation = <<-EOT
    my multi-line
    awesome

    annotation
    EOT

Example annotation that avoids issue: annotation = "my multi-line\nawesome\n\nannotation"

Debug Output

https://gist.github.com/arcticgeek/9c14ec830118c2a2aabb2714dcd693e9

Panic Output

No response

Expected Behavior

Multi-line VM annotations specified as heredocs should trigger no changes when unmodified across plan/apply invocations.

Actual Behavior

Phantom changes to the multi-line annotation are detected even when unmodified.

Steps to Reproduce

apply multi-line annotation to VM resource as heredoc with <<-EOT terraform plan|apply

Environment Details

Windows AMD64 with terraform source code in UTF8 and having CRLF line endings.

Screenshots

No response

References

https://github.com/hashicorp/terraform-provider-vsphere/issues/713

github-actions[bot] commented 3 months ago

Hello, arcticgeek! šŸ–

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.