Skip to content

Preserve nullable volume_tags for aws_instance - #242

Merged
liranfarage89 merged 2 commits into
env0:masterfrom
JSap0914:fix/issue-241-null-volume-tags
Sep 6, 2026
Merged

Preserve nullable volume_tags for aws_instance#242
liranfarage89 merged 2 commits into
env0:masterfrom
JSap0914:fix/issue-241-null-volume-tags

Conversation

@JSap0914

Copy link
Copy Markdown
Contributor

Summary

Preserve the original nullability of aws_instance.volume_tags when Terratag adds volume tags. The generated expression now returns null when the original expression evaluates to null, avoiding the root_block_device.tags conflict while retaining the existing merge behavior for non-null values.

Fixes #241

Changes

  • guard the generated volume_tags merge with an original-value null check
  • add a focused unit regression test for a conditionally-null expression
  • extend the existing aws_instance_volume_tags fixture with the reported conditional pattern

Testing

  • go test ./internal/tagging -run TestTagAwsInstance_PreservesNullableVolumeTags -count=1
  • SKIP_INTEGRATION_TESTS=1 go test ./...
  • go vet ./...
  • go fmt ./...
  • focused TestTerraformlatest/aws_instance_volume_tags fixture run with a local provider-schema stub

JSap0914 and others added 2 commits July 16, 2026 05:47
A literal map can never evaluate to null, so wrapping it in a
`== null ? null : merge(...)` guard only adds noise to generated
output. Keep the guard for dynamic expressions (variables,
conditionals) where it is needed to avoid the
root_block_device.tags conflict.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@liranfarage89 liranfarage89 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. I pushed one small commit on top so the null guard only applies to non-literal expressions (a literal map can never be null, so guarding it just adds noise to generated output). CI is green.

@liranfarage89
liranfarage89 merged commit 0d41b68 into env0:master Sep 6, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants