fix(api_key): support organization-level NRNs in nrn_without_namespace#434
Open
serialito74 wants to merge 1 commit into
Open
fix(api_key): support organization-level NRNs in nrn_without_namespace#434serialito74 wants to merge 1 commit into
serialito74 wants to merge 1 commit into
Conversation
serialito74
marked this pull request as draft
July 13, 2026 11:51
serialito74
marked this pull request as ready for review
July 16, 2026 16:46
slice(split(":", var.nrn), 0, 2) fails with 'Invalid value for "end_index"
parameter' when the NRN has a single segment (organization-level NRN).
Clamp the slice end to the number of available segments so both
organization-only and organization:account NRNs work.
serialito74
force-pushed
the
fix/api-key-org-level-nrn
branch
from
July 16, 2026 16:49
e339cf8 to
05133b2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
nullplatform/api_keycomputes:The unconditional
slice(..., 0, 2)assumes the NRN always has at least two segments (organization=X:account=Y). When the module receives an organization-level NRN (organization=X, a single segment), the plan fails with:This blocks using api_key-based modules (e.g. cloud/orchestration configs, agent associations) at the organization level, which is a supported pattern for multi-account NRN inheritance.
Fix
Clamp the slice end to the number of available segments:
Behavior is unchanged for NRNs with two or more segments; organization-only NRNs now resolve to the organization NRN itself instead of crashing.
Testing
Verified against a real nullplatform organization on Azure/AKS, using a root module that consumes
api_key-based modules with an organization-level NRN (organization=<id>):tofu planfails withInvalid value for "end_index" parameteras soon as the org-level NRN reachesnrn_without_namespace.tofu planandtofu applycomplete successfully: the api_key resource is created and the agent association works with organization-scoped grants.organization=X:account=Y):nrn_without_namespaceoutput is byte-identical to the current behavior, so existing consumers see no diff.tofu validateandtofu fmt -checkclean on the module.