Skip to content

fix(zone): rewrite cross-file .zone references to .name#295

Merged
vaishakdinesh merged 1 commit intomainfrom
fix/zone-cross-file-ref-rewriting
May 7, 2026
Merged

fix(zone): rewrite cross-file .zone references to .name#295
vaishakdinesh merged 1 commit intomainfrom
fix/zone-cross-file-ref-rewriting

Conversation

@vaishakdinesh
Copy link
Copy Markdown
Member

Summary

  • Adds ComputedAttributeMapper to the cloudflare_zone migrator so that cross-file references like cloudflare_zone.example.zone are rewritten to cloudflare_zone.example.name during migration
  • The zonename attribute rename was handled within the resource block, but cross-file references were left unchanged — breaking any resource referencing the zone's domain

Context

Found while reviewing terraform-cfaccounts MR !9482 where a customer had to manually fix .zone.name references in workers_toolbox.tf. Related to APIX-741.

Changes

  • internal/resources/zone/v4_to_v5.go — Implements ComputedAttributeMapper interface with zonename mapping
  • integration/v4_to_v5/testdata/zone/input/zone_cross_refs.tf — New test file with cross-file .zone references (direct, interpolation, locals)
  • integration/v4_to_v5/testdata/zone/expected/zone_cross_refs.tf — Expected output with .name references

Testing

TEST_RESOURCE=zone go test -v -run TestSingleResource ./integration/...
--- PASS: TestSingleResource/zone (1.66s)

The cloudflare_zone resource renamed its 'zone' attribute to 'name' in v5,
but tf-migrate only updated it within the resource block. Cross-file
references like cloudflare_zone.example.zone were left unchanged, breaking
any resource that referenced the zone's domain.

Add ComputedAttributeMapper to the zone migrator so that all cross-file
references to .zone are rewritten to .name during global postprocessing.

Fixes references in string interpolations, locals, and other resources.
Found via review of cloudflare/ops/terraform-cfaccounts MR !9482.
@vaishakdinesh vaishakdinesh force-pushed the fix/zone-cross-file-ref-rewriting branch from 8827ec0 to ee3741e Compare May 1, 2026 18:55
@vaishakdinesh
Copy link
Copy Markdown
Member Author

@vaishakdinesh vaishakdinesh merged commit 1a91567 into main May 7, 2026
12 checks passed
@vaishakdinesh vaishakdinesh deleted the fix/zone-cross-file-ref-rewriting branch May 7, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants