Does Pulumi automatically refresh expired Azure AD service‑principal secrets?
0 reputation · 15 Jan 2023, 21:53 UTC
0 reputation · 15 Jan 2023, 21:53 UTC
Goal: Determine whether Pulumi can automatically detect and renew an expired Azure AD service‑principal secret when using static credentials, while maintaining least‑privilege access.
Constraints/uncertainty: Pulumi reads the secret from environment or config per command; static secrets are not auto‑refreshed, whereas Managed Identity or OIDC flows rely on the underlying Azure SDK to obtain fresh tokens. It is unclear if the Pulumi CLI or provider exposes a hook for external secret rotation or if users must implement their own refresh mechanism.
35275 reputation · 16 Jan 2023, 04:09 UTC
No. Pulumi does not automatically refresh or rotate expired Azure AD (Microsoft Entra ID) service-principal secrets—neither the credentials Pulumi uses to authenticate to Azure, nor secrets it manages as resources such as azuread.ApplicationPassword. Pulumi is a declarative provisioning tool, not a secret lifecycle manager. Rotation must be triggered externally, typically by a scheduled CI job.
It is important to distinguish between the two types of secrets involved:
ARM_CLIENT_SECRET), the Azure SDK refreshes short-lived access tokens during a run, but the underlying client secret is never renewed. When it expires, pulumi up fails with an authentication error until the environment or Pulumi ESC/config is updated.azuread.ApplicationPassword has a fixed endDate. When that date passes, Pulumi does nothing automatically; the resource only changes if you modify its inputs and execute a stack update.rotateTriggers or replace_triggered_by, depending on your provider version). A scheduled CI job then bumps the value and runs pulumi up before the secret expires.Verify your installed provider version with pulumi plugin ls, as rotation-related input names vary across pulumi-azuread releases. Note that replacing an ApplicationPassword invalidates the old secret immediately; ensure consumers can pick up the new value to avoid downtime. You can verify the lack of auto-rotation by creating a password resource with a very short endDate and running pulumi preview after it expires; no change will be detected.
One diagnostic detail to consider: if your goal is strictly provider authentication, moving to OIDC federation is generally preferable to building a custom rotation pipeline.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 16 Jan 2023, 01:14 UTC
Pulumi forwards the client secret directly to the Azure SDK during provider initialization. The SDK never refreshes that value, so if the Azure AD app’s secret expires, the next pulumi up will fail with an authentication error until the secret is updated in the environment or in a referenced secret store. Pulumi itself does not expose a pre‑command callback or a special environment variable to re‑fetch the secret. The usual pattern is to store the secret in Azure Key Vault, reference it via a data source in the stack, and let an external automation (CI job, scheduled task) rotate the Key Vault secret and trigger a stack refresh. Switching to Managed Identity or OIDC federation removes the static secret entirely, as the SDK obtains fresh tokens automatically.