Pulumi Cloud OIDC from Azure DevOps¶
How Azure DevOps pipelines authenticate to Pulumi Cloud and to Azure without a long-lived
PULUMI_ACCESS_TOKEN or client secret anywhere, and how the whole trust is created and
managed as code from this repo.
Status: proven and self-managed
The handshake was proven end-to-end by a standalone CI-persona smoke-test pipeline (build 180769: an Azure DevOps pipeline authenticates to Pulumi Cloud and lists ESC environments with no Pulumi access token anywhere), then hardened into a least-privilege, two-persona model (builds 180845–181029, see Narrowing the identity). Registry-only and sandbox personas were added later; see Four personas, one issuer.
Both sides of the trust are now created by infra/bootstrap itself — the Entra
app registrations, the Azure DevOps service connections, the Pulumi Cloud teams/roles, and
the OIDC issuer's auth policies. Nothing here depends on a Terraform PR in another repo.
Why¶
Storing a Pulumi access token — or an Azure client secret — in a variable group means a long-lived credential that never expires on its own, is copyable, and has to be rotated by hand. Azure DevOps already mints short-lived OIDC id_tokens for Workload Identity Federation service connections; both Entra ID and Pulumi Cloud can be registered as relying parties for them. Every pipeline run gets a fresh, scoped token instead of a standing secret.
How it's built¶
Everything is created by one Pulumi program, infra/bootstrap (Pulumi project
cloud-foundations, stack bootstrap). There is no external repo in the loop and no
manual Azure DevOps or Entra portal step for the steady-state path — only the original,
long-since-completed registration of the Pulumi Cloud OIDC issuer (see
The issuer).
For each Azure environment in Pulumi.bootstrap.yaml (development-sandbox,
shared-services, platformdev, test, qa, uat, prod), the EnvironmentIdentity
component (infra/bootstrap/Environments/EnvironmentIdentity.cs) creates:
- an Entra app registration
iac-<env>and its service principal, granted Owner on that environment's subscription - a Pulumi ESC environment
azure/<env>that logs the app in via OIDC (fn::open::azure-login) — no client secret, noPULUMI_ACCESS_TOKEN - a federated credential on the app trusting Pulumi ESC's own OIDC issuer, scoped to that one
environment (
pulumi:environments:org:saif-corp:env:azure/<env>) — this is what lets the ESC environment mint Azure tokens for the app in the first place - one Azure DevOps service connection per project, named
iac-<env>, in every project listed undercloud-foundations:azureDevOps.projects— anAzureRMconnection usingWorkloadIdentityFederation, backed by the same app - an all-pipelines
azuredevops.PipelineAuthorizationon each of those connections, so no pipeline needs the manual, click-through authorization Azure DevOps otherwise demands the first time it references the connection - a matching federated credential on the app for each of those connections, with its
issuer/subject read back from the connection resource's own exported
workload_identity_federation_issuer/_subjectattributes rather than hand-typed, so they cannot drift from what Azure DevOps actually presents
Those resources are grouped into three child components, split by blast radius rather than by resource type:
| Component | Holds |
|---|---|
WorkloadIdentity |
the Entra app and principal, Owner on the subscription, and (where a required-template check exists) two directory roles and three Microsoft Graph permissions |
EscEnvironmentAccess |
the credential trusting Pulumi Cloud, the azure/<env> ESC environment, and the two team grants |
AzureDevOpsAccess |
one service connection per Azure DevOps project, each with the credential that trusts it and, where the environment has one, its required-template check |
The two access components are independent ways of obtaining a token for the same identity, so revoking one leaves the other intact.
Tenant and organization singletons live under Organization/ instead, because they are shared
by every environment and so belong to none of them:
| Unit | Holds | Shape |
|---|---|---|
MachineTeam ×4 |
a Pulumi Cloud team, its custom organization role, and the assignment binding them — plus any standing grants with no local resource to sit beside | component |
AdminAccess |
the iac-platform-root service connection and the credential that trusts it |
component |
RegistryAccess |
the iac-pulumi-registry Entra app and principal, its Reader grant on the empty pulumi-registry resource group, and a pulumi-registry service connection with its credential per registry project |
component |
RegistryPipelineAuthorization |
the all-pipelines authorization on each pulumi-registry connection, created after the issuer carries that endpoint's CI deny |
component |
EnvironmentPipelineAuthorization |
the all-pipelines authorization on every iac-<env> connection in every environment, created after the issuer, which carries the CI deny for each connection with no required-template check (iac-development-sandbox) |
component |
DirectoryRoles |
the two tenant-singleton directory role activations | loose resources |
OidcTrust |
the OIDC issuer and its auth policies: the elevated and CI rules, plus an allow for the pinned team and a CI deny for each registry and each unchecked iac-<env> endpoint (42 with 10 projects) |
loose resource |
The last two are deliberately not components. The rule this repo applies is that a component
earns its node when its resources share an invariant — remove one and the rest are broken or
meaningless. A Team without its TeamRoleAssignment has no organization access level, so
every pipeline token fails at exchange rather than at deploy; that is an invariant.
DirectoryRoles' two activations need nothing from each other, and OidcTrust declares a
single resource whose policies are inline properties, so neither has one. Grouping them anyway
would be filing by "declared in the same place", which is what a component is not for.
Note also that grouping by provider would be the wrong axis here, however tempting the
Organization/ folder's provider mix makes it look. This program's whole job is federation
between providers: AzureDevOpsAccess reads a service connection's exported issuer and
subject straight into an Entra credential, and EscEnvironmentAccess derives a credential's
subject from an ESC environment's path. Splitting either by provider severs the dependency the
pair exists for. The components are named for what trust they establish — which is why a
future OktaAccess would slot in beside EscEnvironmentAccess as a fourth child of
EnvironmentIdentity, not into an Okta/ folder.
Separately, the AdminAccess component
(infra/bootstrap/Organization/AdminAccess.cs)
creates one more connection, iac-platform-root — the identity that deploys
infra/bootstrap itself. It reuses the pre-existing iac-platform-root app (looked up by
display name, not created here) rather than minting a new one — which is why it is named for
the access path rather than the identity, exactly parallel to AzureDevOpsAccess.
\"platform\" means the platform, not the Platform project
The name comes from cloud-foundations:admin.identityName and refers to the platform as a
whole — it is the root IaC identity for the estate. It is not derived from the Azure
DevOps project that happens to share the name. Which project hosts the connection is decided
independently, by the bootstrap-admin tag in azureDevOps.projects (today: Platform).
Those two were briefly conflated: the name used to be built as iac-{adoProjectName}-root.
That encoded a dependency that does not exist — the Entra app is manually maintained and
always called iac-platform-root — so moving the admin tag to another project would have
renamed the lookup and failed the deploy outright. Move the tag freely; the identity keeps
its name.
flowchart LR
subgraph "Per environment × per ADO project"
ADO[ADO pipeline<br/>AzureCLI@2]
SC["Service connection<br/>iac-<env>"]
end
ADMIN["Service connection<br/>iac-platform-root<br/>(Platform project only)"]
EID[Entra ID<br/>login.microsoftonline.com]
PC[Pulumi Cloud<br/>org saif-corp]
ADO -->|requests id_token| SC
SC -->|federated cred| EID
EID -->|Entra-issued id_token| ADO
ADO -->|az login / az account set| ADO
ADO -->|pulumi login --oidc-token| PC
PC -->|short-lived Pulumi token| ADO
ADMIN -->|deploys bootstrap itself| PC
AzureCLI@2 also performs a real az login / az account set before running your script. If
the backing service principal cannot see the connection's subscription, the task fails there —
before any Pulumi command runs. infra/shared-services/permissions.tf documents this
constraint for other pipelines.
The mechanism is addSpnToEnvironment: true, which exposes the OIDC id_token to the inline
script as $env:idToken. That token is then handed to pulumi login.
The config file is the source of truth¶
infra/bootstrap/Pulumi.bootstrap.yaml drives the whole fan-out. Four stack-config
sections:
config:
cloud-foundations:admin:
identityName: iac-platform-root
environmentName: shared-services
cloud-foundations:azure:
tenantId: <Entra tenant guid>
environments:
- name: development-sandbox
subscriptionId: <guid>
- name: shared-services
subscriptionId: <guid>
displayName: Shared Services
- name: platformdev
subscriptionId: <guid>
displayName: Platform Dev
# test / qa / uat / prod likewise
cloud-foundations:azureDevOps:
organizationId: <Azure DevOps org guid>
organizationName: <Azure DevOps org display name>
projects:
# Every project lists azure-devops-ci, which is what gets it the per-environment
# iac-<env> connections. Exactly one project also lists bootstrap-admin, which
# is what gets it the one-off iac-platform-root connection.
- name: Platform
pulumiTeams: [azure-devops-ci, bootstrap-admin]
- name: Architecture
pulumiTeams: [azure-devops-ci]
# Case-Management / Claims / Corporate / Customer / Documents / Policy /
# Regulatory / SAIF likewise
cloud-foundations:pulumiOidc:
displayName: pulumi-esc-oidc
issuer: https://api.pulumi.com/oidc
audience: azure:saif-corp
subjectPrefix: "pulumi:environments:org:"
Adding an environment (a new subscription) or an Azure DevOps project is a YAML edit and a
pulumi up — no external PR, no manual portal step, no new hardcoded array. Every environment
gets the treatment above, including shared-services (shared resources other pipelines reach into).
The one exception is development-sandbox (ad hoc manual testing), which sets
skipRequiredTemplateCheck: true: its connections get no CheckRequiredTemplate, so pipeline-templates
feature branches can be tested there, and its identity gets no directory roles or Graph permissions,
because any pipeline in the listed projects can obtain a token for it. For the same reason its
connections mint azure-devops-sandbox rather than azure-devops-ci (see The sandbox persona).
It keeps Owner on its subscription and its iac-access-infosec membership. Directory access and the
CI persona follow the check in general: an empty ciRequiredTemplates withholds both from every environment.
Projects are cheap, but not unlimited — 9 slots remain
Entra caps an application at 20 federated identity credentials, and the iac-<env>
applications are per environment, not per project. So each project added to projects:
costs one credential on every application at once, not one in total.
Today that is 10 projects plus the Pulumi ESC credential — 11 of 20 on each of the
seven applications. Nine more projects fit. The tenth fails during pulumi up, on
whichever environment Pulumi happens to reach first, so the error will name an arbitrary
environment rather than the project you just added.
Should that ceiling ever bind, the fix is to stop federating every project against the same per-environment application — either an application per project/environment pair, or a single shared connection projects are granted access to.
The stack imports only bootstrap/*: bootstrap/azure plus the vendor secrets
Earlier revisions of this stack imported azure/<env> back into itself to read
{env}:subscriptionId — circular, since this stack is what creates those environments.
Subscription IDs now live as plain stack config instead (above), and this stack is their
source of truth, not a consumer of it. The stack also no longer imports platform/all
(which existed only to pull in platform/pulumi's long-lived PULUMI_ACCESS_TOKEN) —
Pulumi Cloud auth for deploying this very stack now comes from the iac-platform-root
service connection's OIDC exchange, via a federated credential scoped to
pulumi:environments:org:saif-corp:env:bootstrap/azure.
This environment is manually maintained and deliberately not managed by this stack —
it is what the stack authenticates with, so it cannot be something the stack creates.
It was previously platform/iac-platform-root, then bootstrap/pulumi-config. The
bootstrap/ project namespace is reserved for exactly one category: credentials a
human enters by hand because no stack can create them. Third-party vendor credentials
belong here too, one environment per vendor and tier — bootstrap/okta-np,
bootstrap/okta-prod, bootstrap/dynatrace — so each keeps its own grant boundary while
Pulumi Cloud's project grouping still presents them as a single place to look. The stack
imports all four; the vendor three expose their secret to it through pulumiConfig
(cloud-foundations:oktaPrivateKey-<env>, cloud-foundations:dynatraceClientSecret).
Naming environments after what the credential is for, not what consumes it, is what
makes that namespace scan consistently: bootstrap/azure sits beside bootstrap/okta-prod
and reads the same way. It also means the environment holds only credentials. Non-secret
settings that merely happened to be convenient there belong in stack config instead — the
Azure DevOps organization URL moved out for exactly this reason, and is now derived from
cloud-foundations:azureDevOps.organizationName.
bootstrap/azure is the one asymmetric member of the namespace: its path is baked into a
federated credential subject, so it cannot be renamed or deleted casually (see below). The
vendor environments carry no such constraint.
Only this stack opens bootstrap/*
The generated okta-ext/<tier> and dynatrace/<tier> leaves do not reference
bootstrap/* at all. This stack reads each secret through its own imports and writes a copy
into the leaf as fn::secret, which ESC encrypts on save. Pipelines therefore open the
leaves, or the saif/<env> composites that import them, and azure-devops-ci holds no grant
on bootstrap/*. That grant boundary protects the hand-entered source of truth and its edit
history, not secrecy from CI: CI receives the same secrets through the leaves, and its
org-wide stack:decrypt (see below) can read them from cloud-foundations/bootstrap state.
Rotation is: update the bootstrap/* value, then run this stack. Keeping
the copy in the program also lets it choose what reaches consumers, such as the per-tier
Dynatrace token scopes (see "Provider environments" in infra/bootstrap/README.md).
The rest of this tip is the general rule for any hand-written environment that does reference another.
An explicit imports: entry merges the entire imported environment into the
consumer's resolved output, so every value in bootstrap/okta-prod would be readable
by anyone who can open the importing environment. An
implicit import exposes only the
value actually referenced:
# in a consuming environment — only privateKey crosses the boundary
values:
okta:
privateKey: ${environments.bootstrap.okta-prod.okta.privateKey}
Never import vendor credentials into a broadly-granted environment: any environment
that multiple personas hold an open grant on makes a secret placed there readable by
every pipeline with that grant, whether or not anything imports it. (This guide used to
warn about azure/base specifically — that environment held exactly this shape, both
personas' open grant with nothing importing it, and has since been deleted;
see cloud-foundations#104.)
For explicit imports:, the reader needs open on every environment in the chain. A
missing grant shows up as unknown property, not a permission error, which is why each
infra/bootstrap leaf grants Open to every team that opens a composite importing it.
Whether an implicit ${environments...} reference needs the same grant has not been
verified here, so grant it anyway rather than rely on its absence as a boundary.
Renaming this environment is a two-step change, and cleanup is part of it
The environment path is load-bearing: it is half of the federated credential subject
(pulumi:environments:org:saif-corp:env:<project>/<environment>) that lets ESC mint the
iac-platform-root app's Azure tokens. Add the new subject as an additional federated
credential on that app before switching the environment: import, and only remove the
old one after a real pipeline run proves the new path. Switching the import first leaves
the stack unable to authenticate — including unable to deploy the fix.
Verify the new credential in isolation before switching anything:
That forces the azure-login exchange to actually execute while printing only a
non-secret client id. Expect a OIDC token validation failed with Azure error for the
first minute or so — Entra takes a short while to propagate a new credential, so retry
before concluding the subject is wrong.
Then delete the old environment and its now-orphaned federated credential. A
credential whose environment no longer exists is not inert: its subject is just a string,
so anyone able to create an ESC environment at that exact path can mint tokens for the
app — which here is Owner on seven subscriptions. Two such orphans accumulated in this
tenant from earlier renames (platform/iac-platform-root and platform/all, both 404)
before anyone noticed. Audit with:
az ad app federated-credential list --id <appId> --query "[].{name:name,subject:subject}" -o table
# then, for each pulumi:environments subject, confirm the environment still exists:
pulumi env get saif-corp/<project>/<environment> --definition
Entra also caps an application at 20 federated credentials, so orphans consume a finite budget as well as widening the trust surface.
Deleting a team or an ESC environment in the UI silently orphans its grants
TeamEnvironmentPermission, TeamStackPermission and TeamRoleAssignment are
children of the team and environment they bind. Deleting either side in the Pulumi
Cloud UI removes the grants with it — but Pulumi's state file still records them as
live, and pulumi preview compares desired state against state, not against the
server. The stack therefore reports itself clean while the CI identity has silently
lost access.
This has already happened once here: 13 environment grants, one role assignment and
one stack permission were destroyed out of band and went unnoticed across four
consecutive clean previews. The only thing that surfaces it is
pulumi refresh, which reconciles state against the provider:
pulumi refresh --stack bootstrap # detects the vanished grants
pulumi up --stack bootstrap # recreates them
Verify the repair against the API rather than trusting the resulting state — that is the failure mode being diagnosed:
curl -H "Authorization: token $PULUMI_ACCESS_TOKEN" \
https://api.pulumi.com/api/orgs/saif-corp/teams/azure-devops-ci
Prefer deleting environments and teams through this stack. When something must be
removed in the UI, run a refresh immediately afterwards.
Reference values¶
| Item | Value |
|---|---|
| Azure DevOps organization | SAIFCorporation |
| Azure DevOps org GUID | 7f80b586-0eee-43fa-8743-8d4025b72800 |
| Entra tenant | a86cb8ed-369b-4df5-ace5-43811f6e08cf |
Issuer (iss) |
https://login.microsoftonline.com/a86cb8ed-369b-4df5-ace5-43811f6e08cf/v2.0 |
Audience (aud) |
fb60f99c-7a34-4190-8149-302f77469936 — see below |
| Service connections | iac-<env>, one per environment × Azure DevOps project (config-driven, see above); iac-platform-root in Platform only |
| App registrations | iac-<env>, one per environment; iac-platform-root (admin) |
| Pulumi organization | saif-corp |
The registered audience and the emitted aud claim are different strings
Every federated credential reports its audience as api://AzureADTokenExchange:
$ az ad app federated-credential list --id <app-id> --query "[].audiences"
api://AzureADTokenExchange
But the token actually issued carries the magic GUID form:
Confirmed in build 180769. Pulumi matches the claim in the token, not the value in the
credential, so the policy rule must be the GUID. Using api://AzureADTokenExchange
fails with an audience mismatch. OidcTrust.AadTokenExchangeAudience is set to the GUID for
exactly this reason.
The subject is a canonical Entra identifier, not a readable path. Its grammar is:
| Segment | Encoding | Value here | Varies? |
|---|---|---|---|
eid1 |
literal | Entra subject scheme, v1 | no |
c/pub |
literal | cloud = public | no |
t/{tenant} |
base64url GUID | 7bhsqJs29U2s5UOBH24Izw → a86cb8ed-369b-4df5-ace5-43811f6e08cf |
no |
a/{app} |
base64url GUID | rISbSSETf0KqFyZ8ppdXmA → 499b84ac-1321-427f-aa17-267ca6975798 |
no |
sc |
literal | subject kind = service connection | no |
{adoOrg} |
plain GUID | 7f80b586-0eee-43fa-8743-8d4025b72800 |
no |
{serviceEndpointId} |
plain GUID | one per service connection | yes |
Note the mixed encoding: the tenant and app segments are base64url-encoded GUIDs, while the org and endpoint segments are plain dashed GUIDs.
{app} is Azure DevOps, not one of our app registrations
499b84ac-… is the well-known Azure DevOps first-party application ID — the same value you
pass to az account get-access-token --resource. It identifies Azure DevOps as a whole,
not any individual iac-<env> app.
Because this segment (and everything before it) never varies, the subject says nothing
about which app backs a connection — only that a token came from some Azure DevOps
Entra-federated service connection in this tenant, in this org, from this specific
endpoint. That is exactly what the subject prefix OidcTrust composes pins, and it is why the
CI policy's wildcard (see Choosing the subject rule) covers
every iac-<env> connection this stack creates without listing any of them.
To decode a segment yourself:
$s='rISbSSETf0KqFyZ8ppdXmA'; $p=$s.Replace('-','+').Replace('_','/')
switch($p.Length % 4){ 2 {$p+='=='} 3 {$p+='='} }
[guid]::new([Convert]::FromBase64String($p)).Guid
Verify the Entra discovery document if something looks wrong (confirmed reachable):
curl -s https://login.microsoftonline.com/a86cb8ed-369b-4df5-ace5-43811f6e08cf/v2.0/.well-known/openid-configuration
Why iss and aud are not enough¶
A reference article this work started from suggested iss + aud "will most likely be
sufficient", treating sub as optional. That does not hold here.
Every federated credential registered against this tenant carries the same audience —
api://AzureADTokenExchange as registered, emitted as fb60f99c-7a34-4190-8149-302f77469936.
It is the fixed audience for Entra workload identity federation, so as a rule it excludes
nothing. iss narrows only to the Entra tenant — the whole tenant, not just Azure DevOps or
just this Pulumi program's connections. So an iss + aud policy would accept any Entra
workload identity in the tenant that can obtain this audience, and sub is the only rule
doing real access control.
Both issuer forms exist in this tenant
Some older, unrelated app registrations still present vstoken.dev.azure.com/<orgId>
tokens. Every connection created by this repo uses the Entra form above. Don't assume from
a neighbouring connection which form applies — read the actual federated credential.
Choosing the subject rule¶
Pulumi policy claim values support wildcards: * matches zero or more characters, ? matches
zero or one, and . matches exactly one character — not a literal dot. Don't read these
rules as plain string equality.
The CI rule wildcards only the final segment:
That still pins the Entra tenant, that the token was issued via Azure DevOps rather than some
other workload identity, that it came from the SAIFCorporation organization, and that the
subject is a service connection. It is much tighter than omitting sub. What it does not
pin is which service connection — so any pipeline in any of the projects listed under
cloud-foundations:azureDevOps.projects, using any template-checked iac-<env> connection, can mint the CI
token. The unchecked sandbox connections are the exception, pinned and denied (see The sandbox persona).
Why not pin the endpoint GUID?¶
Considered and rejected, for the same reason it was rejected before this stack owned the
connections: Azure DevOps is the deployment mechanism for these environments, so a pipeline
that can deploy through one iac-<env> connection can deploy through any of them in that
project — pinning a GUID defends against nothing an attacker couldn't reach another way. It
would also multiply the maintenance cost: one rule per environment × project, forever, growing
every time a project or environment is added, versus the single wildcard rule today that covers
new connections automatically.
The one place a GUID is pinned is the elevated (admin) policy — see Four personas, one issuer — because that one connection genuinely should not be reachable from anywhere else.
The tripwire
The wildcard's residual exposure is a hand-made Entra-WIF service connection somewhere
in the tenant that isn't one this stack created. Such a connection would not automatically
gain anything here, since the CI policy's teamName requires the pipeline to explicitly
request azure-devops-ci — but it is worth periodically confirming that every Entra-WIF
Azure DevOps connection in the tenant is one this stack (or a known predecessor) created.
The pulumi-registry and unchecked iac-<env> connections are the sets this stack creates
that the wildcard must not serve, so each carries a pinned CI deny — see
The registry persona and The sandbox persona.
Remember deny always beats allow regardless of rule order or specificity — a deny policy is the reliable way to carve out an exception if a specific connection is ever compromised.
Verifying the handshake¶
The replacement deployment verifies the handshake on every bootstrap PR
Two standalone pipelines proved this handshake and exercised the CI and elevated personas: pulumi-oidc.yml (CI persona, definitions 5595 and 5597) and pulumi-config-admin.yml (elevated persona, definition 5608). We deleted both from .azdo/experiments/. The replacement v2/deployments/pulumi-pulumicloud/ service in SAIF/pipeline-templates supplies the bootstrap deployment configured in .azdo/azure-pipelines-global.yml, using iac-platform-root and bootstrap-admin.
The deployment pins refs/heads/releases/v3. Preview mode omits state refresh, apply, and tag push; apply mode retains those operations. The global pipeline declares trigger: none and pr: none, so it runs only when someone queues it.
Pull requests touching infra/bootstrap/** run .azdo/prs/bootstrap.yml (definition 6771), a read-only pulumi preview using the same persona. Its first run, build 205619, completed the OIDC handshake and preview successfully. Queue the global pipeline with enablePreview: true before a first apply to confirm the diff.
The retired pipelines' findings, caveats and full source live in docs/_internal/pulumi-oidc-experiment-pipelines.md, which this site excludes. That page's "PR validation on infra/bootstrap/**" section explains the read-only PR check in .azdo/prs/bootstrap.yml and the elevated-persona risk it accepts.
What the elevated pipeline established, and what any replacement should still cover: minting
a bootstrap-admin token through iac-platform-root and running pulumi preview on
infra/bootstrap itself. That single command exercises the whole chain — stack read,
open on bootstrap/azure, ESC's federated credential minting Azure tokens, and the
azure/azuread/azuredevops providers authenticating with them — so any broken link fails
the run.
Why the pipeline asserted the token subject
Until build 181564 the issuer carried two rules allowing the admin team: one for
iac-platform-root and one for the old externally-managed connection. A successful login
therefore did not by itself prove the new connection worked — the old one may have satisfied
the policy. The pipeline's expectedEndpointId parameter closed that hole by asserting the
token's sub claim ends with the expected endpoint GUID, and failed loudly when it did not.
That assertion produced the evidence to retire the legacy rule. Carry it forward: it is also the tripwire that would catch the admin persona silently authenticating through some other connection.
Two behaviours worth carrying into any replacement:
- Plain
pulumi previewcompares against the state file, so grants deleted in the Pulumi Cloud UI stay invisible to it. Only--refreshreads the server, and it is the only way to catch that class of drift. pulumi uphas never been run from a pipeline here. Every green run is preview only, so the apply path is unproven.
Generated ESC YAML must be newline-pinned¶
Running this stack from a Linux agent for the first time (build 181555) previewed 8 to update where the same commit previewed 253 unchanged on a Windows workstation.
YamlDotNet writes line breaks through TextWriter.WriteLine(), which emits
Environment.NewLine — CRLF on Windows, LF on Linux. That rendered YAML is the
pulumiservice.Environment resource's input, so every azure/* environment's content was
platform-dependent: a local pulumi up and a build agent would each rewrite all eight back to
their own line endings, indefinitely, churning the very environments the OIDC login path
depends on.
All ESC YAML is therefore serialized through EscYaml, which pins .WithNewLine("\n"). Use
it for any new call site rather than constructing a SerializerBuilder inline.
Don't measure line endings through the PowerShell pipeline
pulumi env get … --definition | Out-String reports CRLF whatever is actually stored,
because PowerShell normalises line endings. Read raw bytes instead:
cmd /c "pulumi env get saif-corp/azure/test --definition > $env:TEMP\d.txt 2>nul"
$b = [IO.File]::ReadAllBytes("$env:TEMP\d.txt")
"CR=$(($b | ? { $_ -eq 13 }).Count) LF=$(($b | ? { $_ -eq 10 }).Count)"
The reliable signal is simpler: if a preview is clean on one OS and dirty on another, something in the program is platform-dependent.
What a successful run looks like¶
--- token claims (configure Pulumi Cloud from these) ---
iss: ***
aud: fb60f99c-7a34-4190-8149-302f77469936
sub: ***
-------------------------------------------------------
Logging in to Pulumi Cloud as org 'saif-corp'
Logged in to pulumi.com as service-account:991b80a7-…
--- pulumi whoami ---
User: service-account:991b80a7-…
Organizations: saif-corp
Token type: team: azure-devops-ci
Token name: Azure DevOps – SAIFCo-1785448625627678
The identity is an ephemeral Pulumi service account, minted per run and named after the OIDC issuer. Nothing is stored.
Environment names are visible to any authorized token
pulumi env ls returns every ESC environment in the organization regardless of how narrowly
the token is scoped — TeamEnvironmentPermission gates opening, not listing. Contents
stay protected; names and structure do not. See
Listing is not permission-gated.
Troubleshooting¶
Start from the printed claims, but expect masking
The smoke test decodes and prints iss, aud and sub. Azure DevOps redacts iss and
sub as *** because they derive from the service connection; aud comes through. For the
masked values, read Graph or the connection's federation details panel.
| Symptom | Likely cause |
|---|---|
unsupported protocol scheme "" |
The backend URL was omitted. Use pulumi login https://api.pulumi.com --oidc-token ..., not pulumi login --oidc-token .... |
No OIDC token was returned (our guard) |
The connection is not using Workload Identity Federation, or addSpnToEnvironment: true is missing. |
idToken is not a JWT (our guard) |
The task exposed something other than a JWT. Check the service connection's authentication scheme. |
Invalid issuer / issuer is not registered: … for org saif-corp |
The issuer registered in Pulumi Cloud does not exactly match the iss claim — it should be https://login.microsoftonline.com/a86cb8ed-…/v2.0, not a vstoken.dev.azure.com URL. Issuer URLs are immutable, so this usually means re-registering. |
| Audience mismatch | The aud rule is almost certainly set to api://AzureADTokenExchange. The emitted claim is the GUID fb60f99c-7a34-4190-8149-302f77469936 — use that. |
| Access denied / no matching policy | Either the sub rule does not match the organization GUID 7f80b586-…, the requested --oidc-team doesn't match any policy's teamName, or a deny policy is winning. |
OIDC token exchange failed: access_denied when requesting the admin team |
Expected from anything other than the iac-platform-root connection. The elevated policy is pinned to that one endpoint GUID — see Four personas, one issuer. |
OIDC token exchange failed: access_denied on iac-development-sandbox |
The pipeline requested azure-devops-ci, the template default, which is denied on unchecked connections. Set config.pulumiTeam: azure-devops-sandbox. See The sandbox persona. |
| Requested token type unavailable | The Pulumi organization's edition does not grant that token type. saif-corp is Business Critical — personal, organization, team and deployment-runner are all available. |
Fails at az account set, before any Pulumi output |
An Entra problem, not a Pulumi one. The service principal cannot see the connection's subscription. |
Narrowing the identity¶
A broad organization / Member Allow policy is what proved the handshake first (build
180769) — it grants more than any deployment pipeline needs. infra/bootstrap now models a
narrower identity in code — teams and roles in Organization/MachineTeam.cs, the issuer's
policies in Organization/OidcTrust.cs — so the model is iterated by editing C#, not by
clicking.
Four personas, one issuer¶
azure-devops-ci |
bootstrap-admin |
azure-devops-registry |
azure-devops-sandbox |
|
|---|---|---|---|---|
| Deploys | app / infra pipelines via template-checked iac-<env> connections |
infra/bootstrap itself, via iac-platform-root |
pulumi-registry connections, one per project |
any pipeline via iac-development-sandbox (no required-template check) |
| Does | pulumi stack tag set and state writes on any stack; pulumi env run … -- terraform apply and pulumi up only where it can also open the stack's ESC environment (not bootstrap, which needs bootstrap/azure) |
creates Entra apps, ESC environments, Azure Owner assignments, the OIDC issuer's own policies | logs in only to publish to and download from the private registry (tf.pulumi.com) |
deploys to the sandbox subscription, on stacks it created |
| ESC | Open on every azure/<env> whose connections carry a check |
Open on every environment it manages (transitive closure — see below) |
none | Open on azure/development-sandbox only |
| Stacks | write and tag every stack (org-wide, see CI writes every stack); full control over the ones it creates (creator grant) | Edit on cloud-foundations/bootstrap, plus the same org-wide write and tag scopes as CI (CiGlobalScopes), because it must hold every scope it grants |
none | full control over the ones it creates (creator grant); Member baseline read elsewhere |
| Org access | stack:create, plus the stack scopes above |
stack:create, every scope in CiGlobalScopes (org-wide on all stacks), environment:create, templates:read, team/role/OIDC-issuer/auth-policy management verbs |
none (Member baseline only) | stack:create |
The only part of sub that varies between connections is the endpoint GUID, and that alone
separates the four identities via extra policies on the same issuer:
| Policy | sub rule |
Mints |
|---|---|---|
| Elevated | pinned to the iac-platform-root connection's endpoint GUID (an Output, not a hardcoded constant) |
team bootstrap-admin |
| CI | …/sc/7f80b586-…/* — any project, any iac-<env> connection |
team azure-devops-ci |
| Registry (one per project) | pinned to each pulumi-registry endpoint GUID |
team azure-devops-registry |
| CI deny (one per project) | pinned to each pulumi-registry endpoint GUID |
refuses team azure-devops-ci |
| Sandbox (one per project) | pinned to each iac-development-sandbox endpoint GUID |
team azure-devops-sandbox |
| CI deny (one per project) | pinned to each iac-development-sandbox endpoint GUID |
refuses team azure-devops-ci |
These do not race each other. The pipeline requests a team
(pulumi login --oidc-team azure-devops-ci), so each policy is an authorization check on a
(sub, tokenType, teamName) triple — proven in build 180845
(Token type: team: azure-devops-ci) and build 180854 (a non-Platform connection's admin
request refused at the exchange, while Platform's succeeds in build 180855). The persona
boundaries hold in both directions.
The cutover rule is gone
Before the registry persona, OidcTrust.Create declared exactly two policies: the
iac-platform-root-pinned elevated rule above and the CI wildcard. A third rule pinned to
the old externally-managed Platform Azure-PulumiCloud endpoint (3ac7d649-…) existed
during cutover so the identity that deploys this stack couldn't lock itself out. Builds
181555 and 181560 proved the new connection mints the admin token, so it was removed and
build 181564 confirmed the admin persona still authenticates without it.
The registry persona¶
pulumi-registry connections, one per project, exist only to log into Pulumi Cloud for the private registry: publishing modules to tf.pulumi.com, and terraform init downloading from it via TF_TOKEN_tf_pulumi_com. They mint azure-devops-registry, a team with no stack grant, no environment grant and no org scope beyond templates:read, which the Member baseline also includes. bootstrap-admin holds it too, because Pulumi Cloud refuses to create a role with a scope the caller's own role lacks. Pulumi Cloud's RBAC has no registry scope (GET /api/orgs/{org}/roles/scopes, checked 2026-09-25), so any org-authenticated token can publish and download, and the team needs nothing more. The role lists templates:read only because the provider rejects an empty permission list and preview cannot prove otherwise; it adds nothing to the Member baseline described below.
The registry allow is pinned per endpoint rather than wildcarded, so an iac-<env> connection can't mint the registry token. The team holds no grants, so the exposure would be small, but it's the same shape as the CI wildcard and costs nothing to avoid.
The CI wildcard also matches these connections. They carry an all-pipelines authorization and no required-template check, so without the pinned denies any pipeline could use one to mint azure-devops-ci and step around the checks on iac-<env>. Deny beats allow regardless of order, which is why this is a deny per endpoint rather than a narrower CI allow. Narrowing the CI allow instead would mean enumerating every iac-<env> GUID, which Why not pin the endpoint GUID? already rejects.
The backing Entra app iac-pulumi-registry follows the iac-<env> pattern: a service principal and one federated credential per connection, with issuer and subject read off the endpoint, so Entra issues the id token. Unlike iac-<env>, the principal holds no directory role, Graph permission or secret, and its only Azure role is Reader on the empty pulumi-registry resource group in shared-services. That grant exists so AzureCLI@2's az account set on the connection's subscription succeeds; it exposes nothing while the group stays empty. Pipelines can use AzureCLI@2 with addSpnToEnvironment: true to read idToken, or fetch the id token from $(System.OidcRequestUri) with serviceConnectionId set to the connection's id. See "Registry access" in infra/bootstrap/README.md for the apply and verification steps.
The sandbox persona¶
iac-development-sandbox sets skipRequiredTemplateCheck so pipeline-templates feature branches can be tested there (#166), and like every iac-<env> connection it is authorized for all pipelines. That makes it usable by any pipeline in any configured project, with no template or branch rule in the way. The CI wildcard used to match it, so any such pipeline could mint azure-devops-ci, open azure/prod and get Owner on the prod subscription (#173).
Those connections now mint azure-devops-sandbox instead, the same pinned-allow-plus-CI-deny shape as the registry persona. The team holds Open on azure/development-sandbox alone and stack:create as its only org scope, so whatever a pipeline gets through the sandbox connection is the sandbox subscription and the stacks that pipeline created. It deliberately does not get CiGlobalScopes: org-wide stack write would let any pipeline decrypt and overwrite every stack's state, prod included.
The rule is "no required-template check", not "named development-sandbox". Any environment that sets skipRequiredTemplateCheck, or every environment if ciRequiredTemplates is empty, deploys as this persona, and CI loses Open on it. Every iac-<env> grant, checked or not, lives in EnvironmentPipelineAuthorization rather than inside WorkloadConnection, so it waits on the issuer the same way the registry grants do and keeps its URN when an environment's check comes or goes. The issuer in turn waits on each checked environment's connections, so toggling skipRequiredTemplateCheck moves the CI deny and the check together in one apply; see "Sandbox access" in infra/bootstrap/README.md.
What it costs pipeline authors:
- Login. A pipeline on
iac-development-sandboxmust setconfig.pulumiTeam: azure-devops-sandbox. The template default,azure-devops-ci, is refused at the exchange. - Stacks. A stack a person created, or one CI created before the split, gives the sandbox team only the Member baseline's read, so the first write 403s the way build 208092 did. Let the pipeline create its own sandbox stacks, or have an org admin grant the team on that stack.
Where the grants live¶
Environment access for the CI and sandbox personas is granted next to the environment it grants, inside
the EscEnvironmentAccess component — every azure/<env> this stack creates gets its CI or sandbox
TeamEnvironmentPermission in the same commit, so an environment and its pipeline access cannot
drift apart.
None of the four teams has a human member, which makes their grants a ceiling for machine tokens rather than something a person inherits.
Pulumi Cloud adds whoever first applies the stack as a team admin
Team membership is populated at create time and cannot be declined: whichever identity
runs the first pulumi up is added to every team (azure-devops-ci, bootstrap-admin, azure-devops-registry and azure-devops-sandbox) as an admin. That is normally the
organization service account, but a human running the initial apply is added instead — as
happened when this stack was rebuilt from empty. Remove them from each team by
hand afterwards, including teams added later such as azure-devops-registry and azure-devops-sandbox:
curl -X PATCH -H "Authorization: token $PULUMI_ACCESS_TOKEN" \
-d '{"memberAction":"remove","member":"<github-login>"}' \
https://api.pulumi.com/api/orgs/<org>/teams/<team>
Removing the member produces no Pulumi diff, because the provider only acts on changes to the declared list — see below.
Check membership rather than assuming it, since GET /teams reports members: 0 for every
team; fetch each team individually. When a team genuinely has no members the response omits
the members key altogether rather than returning an empty array — so verify the key's
presence before counting, or a language that wraps null into a one-element array (as
PowerShell's @($x) does) will report one phantom member and send you chasing a removal
that already worked.
Declaring Members empty is intent, not enforcement — and IgnoreChanges makes it worse
An empty Members list does not remove whoever Pulumi Cloud added: the provider acts
only on changes to the declared list, so a member it never saw declared is left alone
indefinitely. Declaring it empty records intent and nothing more.
IgnoreChanges on Members is actively harmful here, and the reason is the reverse of the
intuition. It substitutes the live value into the desired inputs, so a declared [] and
a cloud-populated ['someone'] are guaranteed to disagree on every run — the option
causes a permanent ~members diff rather than suppressing one. It was removed; the
preview went clean at 274 unchanged with no update even attempted.
Two scope vocabularies exist and are easy to confuse. stack:read / environment:open are
entity scopes, granted per entity by TeamStackPermission / TeamEnvironmentPermission. A
global-resource-type OrganizationRole carries only the org-wide verbs:
| Operation | Needs | Granted by |
|---|---|---|
pulumi preview / up on an existing stack |
stack:read / stack:write |
TeamStackPermission, the creator grant (see below), or a flat stack scope on the role — CI's route |
pulumi stack tag set / rm |
stack_tags:update |
same as above |
| Create a new stack | stack:create |
OrganizationRole (global) |
pulumi env run / pulumi env open |
environment:open |
TeamEnvironmentPermission |
| …on everything it imports, transitively | environment:open |
TeamEnvironmentPermission |
| Create a new ESC environment | environment:create |
OrganizationRole (global) |
The authoritative scope catalogue is the getOrganizationRoleScopes data source, or
GET /api/orgs/{org}/roles/scopes.
Pulumi Cloud silently drops team:list
It's in the catalogue but discarded on write — ask for it and read the role back, and it is
simply absent, no error. Worse, Pulumi's state keeps what you declared, so pulumi preview
stays clean and the gap never surfaces from the CLI. AdminGlobalScopes leaves it out so the
code matches what the server actually stores; confirm any future scope change with
GET /api/orgs/{org}/roles/{roleId}, not pulumi preview.
Create-if-absent, and what it costs¶
Pipelines create their own stacks on first deploy. stack:create is the only stack
creation scope CI needs, and no TeamStackPermission is provisioned ahead of a pipeline's first
run. This is a deliberate departure from the Terraform estate, which splits
bootstrap from deploy purely as a workaround for Terraform Cloud variable-set mapping; that
split is not being carried over.
What makes it work is Pulumi Cloud's creator grant: whoever creates a stack (or an ESC
environment) automatically gets full control over it, with no corresponding
TeamStackPermission needed. Build 181027 proved it for CI — holding stack:create and zero
stack grants:
The same mechanism explains why the admin persona opens every azure/<env> environment (and,
during cutover, every auth/azure-<env> this stack used to own) while holding no
TeamEnvironmentPermission on most of them: it created them.
The creator grant is full control, including delete
The team above deleted the stack it had just created, despite the role carrying no
stack:delete and the team holding Stack Admin nowhere. Under create-if-absent, CI can
delete its own production stacks, and no role in MachineTeam.cs can restrain that
— the grant is issued by Pulumi Cloud at creation time, not by anything declared here.
Mitigation is out of band: the org's Allow stack admins to delete stacks toggle, or
accepting it as the price of having no bootstrap step.
CI writes every stack¶
The creator grant covers only stacks CI created. Most Terraform-migrated stacks are created by hand (pulumi stack init, or the first terraform init run by a person), so on those CI held nothing beyond the Member baseline's Stack Read. Reads worked, and the first write failed. Build 208092 hit it on pulumi stack tag set terraform:execution-mode local with error: [403] You do not have permission to perform this operation. right after terraform init on the same stack succeeded. pulumi up and Terraform state writes fail the same way.
CiGlobalScopes in MachineTeam.cs closes that gap with flat stack scopes on CI's global role. They apply to every stack in the org, the same mechanism the built-in Member role uses for its Stack Read (GET /api/orgs/{org}/roles/{memberRoleId}, checked 2026-09-29). The list is the part of the Stack Write permission set the pipeline templates use:
| Scope | Used by |
|---|---|
stack:read, stack:export, stack:encrypt, stack:decrypt |
stack select, stack output, previews and secrets. The Member baseline already grants these; they are listed so CI keeps working once the baseline drops to None |
stack:write, stack:import |
pulumi up / refresh, Terraform plan/apply state and lock writes |
stack:cancel_update |
releasing a lock stranded by a cancelled run |
stack_tags:update |
the terraform:execution-mode pin and the provenance tags |
Left out on purpose: stack_deployment*, stack_schedule* and stack_webhook*. No template uses them, and they would let a CI token start Pulumi Deployments runs or ship stack events to an arbitrary endpoint. stack:delete, stack:rename and stack:transfer stay with Stack Admin.
This includes stacks CI does not deploy
The grant is org-wide, so a CI token can write cloud-foundations/bootstrap state too. It still cannot run that stack, because it holds no Open on bootstrap/azure. It can corrupt or roll back that stack's state, and nothing here prevents that. A tag-based rule would narrow the grant, but it needs a tag on every stack before CI's first write, which reintroduces the bootstrap step this design avoids.
Among the connections this stack manages, only template-gated ones can mint this token. iac-development-sandbox has no required-template check, so its connections are denied azure-devops-ci and mint the narrower azure-devops-sandbox instead (see The sandbox persona). Before that split, any pipeline in any configured project could reach this grant, and Open on every azure/<env>, through the sandbox connection (#173). The CI allow still wildcards every service endpoint in the Azure DevOps organization, so a hand-made or predecessor Entra-WIF connection with no check could request it too; that is the tripwire this design accepts.
Adding these scopes followed "Adding an org scope" in infra/bootstrap/README.md: bootstrap-admin must hold them before the pipeline can put them on CI's role.
The elevated persona's environment grants are a transitive closure, plus creator access¶
A TeamStackPermission says nothing about environments, so the persona needs open grants of
its own — and each one must be the transitive import closure of what it consumes, not just
the environments it names, because Pulumi checks permission at every link of an import chain.
Missing a link fails misleadingly: a refused import resolves to
nothing rather than raising, so it surfaces as unknown property "subscriptionId" rather than a
permission error pointing at the actual missing grant.
Those grants live beside the resource they grant on, so most of them are not in
MachineTeam.cs at all: the per-environment grants sit in EscEnvironmentAccess, next to the
environments they open. What remains on MachineTeam.CreateAdmin as ExternalEnvironments is
only the closure with no local resource to sit beside: the four bootstrap/* environments
(azure, okta-np, okta-prod, dynatrace), which this stack consumes but does not
create. azure-devops-ci has no ExternalEnvironments. The provider leaves and saif/<env>
composites carry their own grants in ProviderEnvironment and CompositeEnvironment.
Do not read this persona's blast radius off its grant list
bootstrap-admin opens every environment infra/bootstrap manages — via the
creator grant, not its declared grants — while correctly being refused environments the
stack does not manage. When writing a negative assertion for this persona, target an
environment the stack doesn't own, or it will always open.
Effective permissions are a union, so the org-wide defaults matter more than the roles¶
Pulumi Cloud computes effective permissions as the union of a principal's own organization role and every role assigned to teams it belongs to — team roles add to the baseline, they don't replace it. All four teams here resolve to the org service account, which carries the built-in Member role, whose reach for stacks/environments is set org-wide by two UI-only dropdowns under Settings → Access management → Roles → organization-wide role settings (no REST route, no provider resource).
Build 181022 showed what that costs today: the CI team, holding zero stack grants, read an unrelated project's stack in full (metadata, full state export, latest update — all HTTP 200). Environments were correctly refused, pinning the asymmetry to Stack permissions ≥ Read, Environment permissions = None.
Stack scoping is decorative until that dropdown is None
No experiment run against this org can currently prove a stack-level scope is honoured,
because the Member baseline already supplies read regardless of what any role here declares.
Setting Stack permissions to None is a pending, org-level, UI-only change — tracked
separately, not blocking anything documented above.
A related, previously-wrong assumption: a global-resource-type role was thought to reject
entity scopes like stack:read / environment:open. It does not — POSTing one with all four
returns 200 and reads them back; only team:list is dropped, per the warning above. So a global
stack:read (or a tag-based ABAC rule) is a real option for granting StackReference access at
scale, once the dropdown above makes it testable.
The issuer¶
The Pulumi Cloud OIDC issuer is an ordinary managed resource in this stack — created by
pulumi up, not registered by hand. It was originally registered in the UI and adopted with a
one-time ImportId fed by a cloud-foundations:oidcIssuerId config value; both have since been
removed, and a later teardown/rebuild created the issuer from empty, which proved the create
path that adoption had until then kept untested.
Removing the config value retired a genuine footgun. It was load-bearing in a way its name did
not suggest: clearing it made Create return early, which dropped the issuer from the program,
and pulumi up would then delete the registered issuer along with every auth policy —
locking out every persona, including the one that deploys this stack. There is now no config
value to clear.
Never pin the issuer thumbprint
OidcIssuer accepts a Thumbprints list, and reading the live value back into the source
as a constant looks like sound practice. It is a trap: the thumbprint belongs to
Microsoft's TLS certificate, not to this configuration, so pinning it makes the resource
fail the moment that certificate rotates:
error creating oidc issuer: 400 Bad Request:
Calculated thumbprint 5cc383ad… does not match any of the provided.
Adoption hides this — an imported issuer never re-validates — so the failure surfaces only
on the first real create, potentially long after the pin was introduced. The rebuild
demonstrated the volatility directly: the value Pulumi calculated during the failure and the
value it stored minutes later on success were different again. Leave Thumbprints
unset, which is what registering through the UI does.
The issuer URL is still replace-on-change
Url and Organization are replace-on-change and the URL is immutable server-side, so
changing the tenant id re-registers the issuer and takes every policy with it — a lockout
reached a different way. A genuinely new stack creates its own issuer, which is the intended
behaviour; this stack must keep pointing at the tenant it already trusts.
To stop managing the issuer without destroying it, remove it from state with
pulumi state delete rather than deleting the resource from the program.
Policies aren't readable over REST
Every /oidc/issuers/{id}/… policy route 404s, so the live policy list can't be fetched
directly. Read them from pulumi stack export (they are stored as properties of the
OidcIssuer resource) or from pulumi preview --diff.
The provider's own permissions helper is unusable on the current .NET SDK
OrganizationRole.Permissions is a descriptor tree keyed by a __type discriminator, and
the provider ships BuildAllowPermissions to build it. The .NET SDK — not the helper —
strips __-prefixed keys while deserializing invoke results, in
Deserializer.DeserializeStruct. BuildAllowPermissionsResult.Permissions is an untyped
ImmutableDictionary<string, object>, so the discriminator is just a key inside it and gets
filtered out with the rest. The descriptor reaches the provider without it (failed to parse
permission descriptor: type '' not recognized). MachineTeam.cs hand-authors the literal
InputMap<object> instead, which works because the serializer has no matching filter on the
input path — __type is legal outbound and only unreadable inbound.
Still present in Pulumi 3.110.0, in 3.110.1-alpha, and on main; reported upstream as
pulumi/pulumi-dotnet#1102. pulumi/pulumi#22738 is the Python twin, accepted and fixed
there. Provider 1.3.0 renamed the discriminator to kind at the SDK boundary
(pulumi-pulumiservice#778), so the helper may round-trip cleanly now — confirm with a
real invoke before dropping the workaround.
Resource discovery with Pulumi Insights¶
Each environment also gets a Pulumi Insights account that scans its subscription and
indexes what it finds, so the estate can be searched for resources that no Pulumi stack
manages. Environments/InsightsDiscovery.cs creates one InsightsAccount per environment.
It adds no new credential path, which is the whole reason it is cheap. Pulumi's Azure
Insights recipe asks for an OIDC federated credential with audience azure:<org> and
subject pulumi:environments:org:<org>:env:<project>/<env>, plus an ESC environment
exposing fn::open::azure-login with oidc: true. The azure/<env> environments this
stack already creates satisfy that exactly — so the account selects an existing environment
by name rather than provisioning a parallel identity:
That is the console wizard's "Connect using existing ESC credentials" option, expressed in code.
bootstrap-admin needs Insights scopes
Creating an account takes the org-settings scope insights_account:create; refreshing or
changing one takes insights_account:read and insights_account:update. All three are in
AdminGlobalScopes. Without create, adding an environment 403s at the account
(You do not have permission to perform this operation, build 211604). insights_account:delete
is deliberately absent, so removing an environment needs a human org admin.
The scanner inherits Owner
Reusing the ESC environment means the scanner authenticates as iac-<env>, which holds
Owner on the subscription. Insights needs only read. This is not a regression —
Pulumi Cloud could already open azure/<env> and mint that token, so attaching Insights
widens what Pulumi Cloud does with a credential it could already obtain, not what it
can obtain. It is still more privilege than a read-only scan warrants, and a natural
place to narrow later.
Two knobs, because a playground is not an inventory¶
The scan schedule has an estate-wide default and a per-environment override:
cloud-foundations:insights:
scanSchedule: daily # optional; daily when absent
cloud-foundations:azure:
environments:
- name: development-sandbox
insightsScanSchedule: none # a playground produces churn, not an inventory
Accepted values are none, 12h and daily. none genuinely disables scanning rather
than merely recording an intention — verified by reading scheduledScanEnabled back from
the API, which is false for the sandbox and true for the other six.
Accounts are named azure-<env>, with a hyphen¶
Insights reads / in an account name as hierarchy, where a scan or a delete on a parent
cascades to its children. The seven subscriptions are peers, not a tree, so azure/<env>
would misdescribe the relationship and make a delete far more dangerous than it looks.
DependsOn here is load-bearing
Environment is passed as a plain string, so Pulumi sees no data dependency on the ESC
environment. Account creation validates the credential immediately and 404s if the
environment does not exist yet, so InsightsDiscovery takes an explicit DependsOn on
it.
Verifying a scan actually ran¶
scanStatus on the account is always empty — do not read it
GET …/accounts/{name} returns a scanStatus object that stays blank
({id: "", status: "", startedAt: "0001-01-01…"}) no matter how many scans have
succeeded. Reading it suggests scanning is broken when it is working perfectly. The real
history is a separate sub-resource:
which returns scanStatuses[] with status, startedAt and finishedAt. All seven
accounts report succeeded, taking roughly two minutes each.
Discovered resources are not under the account — …/accounts/{name}/resources 404s.
They are in the org-wide resource search:
Finding undocumented Pulumi Cloud routes
Note the shape: preview leads the path and there is no orgs segment, so none of
these routes are guessable. Every attempt to infer them returned 404. They were recovered
by scanning the provider plugin binary's string table for route templates:
$exe = "$env:USERPROFILE\.pulumi\plugins\resource-pulumiservice-v1.3.0\pulumi-resource-pulumiservice.exe"
[Text.Encoding]::ASCII.GetString([IO.File]::ReadAllBytes($exe)) |
Select-String -AllMatches 'api/[a-z/{}]*insight[a-z/{}]*' |
ForEach-Object { $_.Matches.Value } | Sort-Object -Unique
The technique generalises to any Pulumi Cloud endpoint the docs do not cover: the provider must contain the literal it calls.
- Pulumi Cloud OIDC documentation
- Pulumi ESC – Configuring OIDC for Azure
- Using OIDC authentication between Azure DevOps and Pulumi Cloud
— useful background on the general pattern, but it describes the
vstoken.dev.azure.comissuer form and a readablesc://subject. Neither matches this tenant; see Reference values for what actually appears on the wire here.