← Back to Pull requests

fix: Populate immutable workload identity fields on import #132

Closed
unknown closed this pull request without merging on Oct 14, 2026 23:03 UTC
View on GitHub
unknown unknown commented on Oct 14, 2026 21:01 UTC
Author

Description

Importing a beyondtrust_auth_workload_identity always planned a destroy and recreate.

Read deliberately keeps service_name, issuer_url and idp_category from prior state, because the auth service lower-cases some of these in storage and echoing them back would cause spurious diffs. After an import, though, those fields are null, and all three force replacement, so every import planned a replace. A replace gives the identity a new identityId. For identities whose conditions are managed outside Terraform, it also resets them to the config's seed values, so their workloads stop authenticating.

Change

  • applyRead now fills these three fields from the API response when the state value is null. That only happens on the first Read after ImportState. All three are Required, so after a create they always hold config values. Refresh behaviour for managed resources is unchanged.

  • An empty value in the response leaves the field null rather than writing "".

  • The acceptance test no longer uses ImportStateVerifyIgnore for these fields, so it now checks that they round-trip exactly.

  • New acceptance step: an import using an import block (ImportStateKind: resource.ImportBlockWithID) against the same config. The step fails if the import plans anything other than a no-op.

  • Unit tests cover filling null fields and the empty-response case.
  • Behaviour notes

  • A state imported with an earlier version but never applied is fixed on its next refresh: the planned replace goes away.

  • A config value that differs from the stored value only by case still plans a replacement. The plan diff now shows the stored value instead of null. Comparing these fields case-insensitively would fix this, but that is a larger change and is out of scope here.
  • Motivation

    This unblocks adopting existing, unmanaged workload identities into Terraform state for the platform-eventing tenant-onboarding stack.

    Jira tickets and links


  • Jira: ON-6764
  • [ON-6764]: https://beyondtrust.atlassian.net/browse/ON-6764?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 278 lines (+208 / -70) across 3 files Reviewer: sdahal-bt Review duration: 121m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 278 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.337
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #132"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 39.6% (MEDIUM) · Higher = larger blast radius
    39.6%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 15.7% · Safe to merge
    15.7%