← Back to Pull requests

Add the join key and host resources #7

Open
unknown opened this pull request with 349 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 06, 2026 02:19 UTC
Author

definednet_join_key manages a reusable enrollment secret scoped to a network,
role and tags. The shape is immutable, so changing it replaces the key; name
and expires_at update in place. The token is returned only on create and is
stored sensitive in state. Hosts enrolled with a key stay outside Terraform.

definednet_host manages a host record for lighthouses, relays and other hosts
whose identity must exist before they boot. ipv4_address can be set at create
or added in place to a host without one; ip_addresses mirrors the API's list.
Enrollment codes are minted outside Terraform.

A plan-time check on both the join key and the endpoint OIDC provider rejects
an empty auto_assign_cidrs on a certificate version 1 network, where the API
always assigns IPv4. For a join key the check matters because a replace
deletes the old key before the API could reject the new one.

The host is created through POST /v2/host-and-enrollment-code so its
single-use enrollment code lands in state (sensitive) and can feed the
machine's user data. A change to the enrollment_code_triggers map mints a
new code; the triggers of an existing host must be known at plan time,
because Terraform re-plans during apply and a value resolving equal to the
stored map would keep a consumed code after the dependent machine was
destroyed. Update sends the PUT only when a field it owns changed, since the API
writes an audit entry for every PUT, and commits the add-IP and PUT results
with the previous code and triggers, so a failed mint on a blocked host
leaves the trigger change pending. GET never returns the code, so Read carries it forward and an
imported host has none until its triggers change. The lifetime is stored
only as configured; omitted, the API applies its one-day default. The
combined route needs the hosts:enroll scope as well.

Verification

  • go test ./... green (fake API).

  • TF_ACC=1 suite passed live against the test org, 26/26, including the host and join key tests: the combined

  • create route mints codes, a trigger change mints a fresh one, add-IP in place, out-of-band deletes, and join
    keys (the JOIN_KEYS flag is on for the test org).
  • Review panel: three rounds on the join key and host resources, one round plus a design check and a second

  • round on the enrollment code, and a light review of the PUT skip.

    Notes for the reviewer

  • The API key needs hosts:enroll in addition to the host scopes, because POST /v2/host-and-enrollment-code

  • requires both.
  • Terraform re-plans during apply, so enrollment_code_triggers must be fully known on an existing host; the plan

  • modifier rejects unknown values with an error that says how to fix it.
  • Join key expires_at is a UTC-only ...Z string compared as text; the API always returns UTC whole seconds.
  • Diff: 349 lines (+261 / -88) across 4 files Reviewer: jasikpark Review duration: 24101m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.47) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 349 lines diff across 4 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.350
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #7"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.4% (MEDIUM) · Higher = larger blast radius
    47.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.1% · Safe to merge
    27.1%