refactor: collapse cdn.tf pullzones into for_each #80

Closed
pat-s wants to merge 1 commit from pr/cdn-tf-for-each into main
Owner

Summary

The two bunnynet_pullzone resources (devxy-r-binaries / cran.devxy.io and cran_rpkgs_com / cran.rpkgs.com) and their bunnynet_pullzone_hostname siblings were byte-for-byte identical except for the zone name and hostname.

Collapses both into a for_each over a local.pullzones map. Shared knobs (block_ips, limit_bandwidth, s3_auth_*, cache_*, …) now live in one place.

Before applying

Resource addresses change:

Old New
bunnynet_pullzone.devxy-r-binaries bunnynet_pullzone.this["cran"]
bunnynet_pullzone.cran_rpkgs_com bunnynet_pullzone.this["cran-rpkgs"]
bunnynet_pullzone_hostname.devxy-r-binaries bunnynet_pullzone_hostname.this["cran"]
bunnynet_pullzone_hostname.cran_rpkgs_com bunnynet_pullzone_hostname.this["cran-rpkgs"]

The PR includes moved {} blocks for each, so terraform plan should report zero in-place / destroy / create for the four resources — just state shuffling.

Verify before applying:

terraform plan -refresh=false

Output should show four Move from ... to ... notices and zero +/-/~ for the pullzones/hostnames. If anything else changes, abort.

Follow-up

Once a successful apply has run on every workspace, the moved {} blocks can be removed in a follow-up commit (they're a no-op after migration).

## Summary The two `bunnynet_pullzone` resources (`devxy-r-binaries` / cran.devxy.io and `cran_rpkgs_com` / cran.rpkgs.com) and their `bunnynet_pullzone_hostname` siblings were byte-for-byte identical except for the zone name and hostname. Collapses both into a `for_each` over a `local.pullzones` map. Shared knobs (`block_ips`, `limit_bandwidth`, `s3_auth_*`, `cache_*`, …) now live in one place. ## Before applying Resource addresses change: | Old | New | |---|---| | `bunnynet_pullzone.devxy-r-binaries` | `bunnynet_pullzone.this["cran"]` | | `bunnynet_pullzone.cran_rpkgs_com` | `bunnynet_pullzone.this["cran-rpkgs"]` | | `bunnynet_pullzone_hostname.devxy-r-binaries` | `bunnynet_pullzone_hostname.this["cran"]` | | `bunnynet_pullzone_hostname.cran_rpkgs_com` | `bunnynet_pullzone_hostname.this["cran-rpkgs"]` | The PR includes `moved {}` blocks for each, so `terraform plan` should report **zero in-place / destroy / create** for the four resources — just state shuffling. Verify before applying: ``` terraform plan -refresh=false ``` Output should show four `Move from ... to ...` notices and zero `+/-/~` for the pullzones/hostnames. If anything else changes, abort. ## Follow-up Once a successful apply has run on every workspace, the `moved {}` blocks can be removed in a follow-up commit (they're a no-op after migration).
bunnynet_pullzone.devxy-r-binaries (cran.devxy.io) and
bunnynet_pullzone.cran_rpkgs_com (cran.rpkgs.com) were byte-for-byte
identical except for the zone name and hostname. Same for the two
pullzone_hostname resources.

Use a single local.pullzones map and for_each on both resources, so
shared knobs (block_ips, limit_bandwidth, s3_auth_*, ...) only have
to be edited once.

State migration is handled by moved {} blocks so the existing
pullzones get re-addressed under the new for_each keys instead of
being destroyed+recreated. Run terraform plan to confirm a zero-
change apply before applying.
Author
Owner

Closing — the duplication this PR was solving no longer exists.

In 44482b1 the bunnynet_pullzone.devxy-r-binaries (cran.devxy.io) and its hostname + storage zone were commented out, and the surviving cran_rpkgs_com resource has since diverged with new fields (middleware_script, routing { filters }, cache_expiration_time, websockets_enabled, errorpage_whitelabel, cache_errors = false, …) that the deleted resource never had.

A future for_each refactor (if more pullzones come back) should be designed against the new shape, not this one. Closing as obsolete.

Closing — the duplication this PR was solving no longer exists. In `44482b1` the `bunnynet_pullzone.devxy-r-binaries` (cran.devxy.io) and its hostname + storage zone were commented out, and the surviving `cran_rpkgs_com` resource has since diverged with new fields (`middleware_script`, `routing { filters }`, `cache_expiration_time`, `websockets_enabled`, `errorpage_whitelabel`, `cache_errors = false`, …) that the deleted resource never had. A future `for_each` refactor (if more pullzones come back) should be designed against the new shape, not this one. Closing as obsolete.
pat-s closed this pull request 2026-06-12 13:38:47 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
devxy/build-cran-binaries!80
No description provided.