Skip to content

fix(infra): grant Secrets Officer to whoever is actually running the script - #112

Merged
bgard68 merged 1 commit into
mainfrom
fix/provision-service-principal
Sep 2, 2026
Merged

fix(infra): grant Secrets Officer to whoever is actually running the script#112
bgard68 merged 1 commit into
mainfrom
fix/provision-service-principal

Conversation

@bgard68

Copy link
Copy Markdown
Owner

The vault grant resolved the caller with az ad signed-in-user show, which
only answers for a human. Run as a service principal -- any CI invocation --
it returns nothing, and that empty id went straight into the role assignment
whose failure was swallowed by 2>&1 | Out-Null. The grant silently did not
happen and the script continued, failing several steps later at the secret
writes with an error pointing at the wrong thing.

The caller is now resolved either way: signed-in user first, falling back to
the service principal the CLI is authenticated as. If neither resolves, or if
the role is absent afterwards, the script throws where the problem is rather
than letting a later step fail for a reason that reads as unrelated. The end
state is verified by querying the assignment, because role assignment create
returns non-zero when the assignment already exists -- so neither exit code
alone distinguishes "granted" from "was already granted" from "failed".

Found while auditing the sibling repo's provisioning scripts after the same
class of defect surfaced there (ToDoApp #166), where an ungated signed-in-user
lookup under set -e killed the script outright.

Co-Authored-By: Claude Opus 5 noreply@anthropic.com

…script
The vault grant resolved the caller with `az ad signed-in-user show`, which
only answers for a human. Run as a service principal -- any CI invocation --
it returns nothing, and that empty id went straight into the role assignment
whose failure was swallowed by `2>&1 | Out-Null`. The grant silently did not
happen and the script continued, failing several steps later at the secret
writes with an error pointing at the wrong thing.
The caller is now resolved either way: signed-in user first, falling back to
the service principal the CLI is authenticated as. If neither resolves, or if
the role is absent afterwards, the script throws where the problem is rather
than letting a later step fail for a reason that reads as unrelated. The end
state is verified by querying the assignment, because `role assignment create`
returns non-zero when the assignment already exists -- so neither exit code
alone distinguishes "granted" from "was already granted" from "failed".
Found while auditing the sibling repo's provisioning scripts after the same
class of defect surfaced there (ToDoApp #166), where an ungated signed-in-user
lookup under `set -e` killed the script outright.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@bgard68
bgard68 merged commit 4864f01 into mainSep 2, 2026
7 checks passed
@bgard68
bgard68 deleted the fix/provision-service-principal branch September 2, 2026 20:00
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@bgard68