Structured source/dest schema + computed set_name; fix the README example #9

Open
opened 2026-07-26 17:13:35 +10:00 by benvin · 0 comments
Owner

Problem 1 — live doc bug. The README example creates
tomswallapi_address_group named cloudflare but the rule references
+asn_cloudflare. Either the example is wrong or there's implicit asn_
prefixing magic; both are footguns when selectors are hand-typed strings.

Problem 2 — stringly-typed DSL. source = ["net:+asn_cloudflare"] embeds
a mini-grammar in strings: no Terraform-native references, no plan-time
validation, no dependency edges (Terraform can't know the rule depends on the
group, so destroy ordering is luck).

Proposal.

  • Expose a computed set_name attribute on tomswallapi_address_group.

  • Accept structured elements alongside (eventually instead of) strings:

    source = [{ zone = tomswallapi_zone.net.name,
                group = tomswallapi_address_group.cloudflare.set_name }]
    

    References give correct dependency ordering for free and make the
    bare-selector-without-zone case unrepresentable in the schema.

  • Fix the README example either way.

**Problem 1 — live doc bug.** The README example creates `tomswallapi_address_group` named `cloudflare` but the rule references `+asn_cloudflare`. Either the example is wrong or there's implicit `asn_` prefixing magic; both are footguns when selectors are hand-typed strings. **Problem 2 — stringly-typed DSL.** `source = ["net:+asn_cloudflare"]` embeds a mini-grammar in strings: no Terraform-native references, no plan-time validation, no dependency edges (Terraform can't know the rule depends on the group, so destroy ordering is luck). **Proposal.** - Expose a computed `set_name` attribute on `tomswallapi_address_group`. - Accept structured elements alongside (eventually instead of) strings: ```hcl source = [{ zone = tomswallapi_zone.net.name, group = tomswallapi_address_group.cloudflare.set_name }] ``` References give correct dependency ordering for free and make the bare-selector-without-zone case unrepresentable in the schema. - Fix the README example either way.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unkin/terraform-provider-tomswallapi#9