Cannot create already existing resource – when creating a ContainerApp in 2 steps (bootstrap + final) with system-assigned managed identity #22083
Replies: 2 comments
-
|
The two- Here is how to solve this cleanly: Use
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
I'm using Pulumi (Python) with
pulumi-azure-nativeandpulumi-azureadto deploy an Azure Container App with a system-assigned managed identity, where that identity must be a member of an existing Entra ID group (which already hasAcrPullon an ACR andKey Vault Secrets Useron a Key Vault).Because the managed identity's
principal_idonly exists after the Container App is created, and because the ACR registry config requires the identity to already haveAcrPullbefore the app can pull the private image, I'm trying a three-step approach:Create the Container App with a system-assigned identity and a public bootstrap image (no ACR config).
Add the identity's service principal to the existing Entra group.
Update the Container App with the private image and
registries[].identity = "system".I modelled steps 1 and 3 as two separate
ContainerAppPulumi resources targeting the same Azure resource name, withparent=bootstrapanddepends_on=[membership]on the final resource.Problem
pulumi upfails on the secondContainerAppresource with:This makes sense: Pulumi tries to create
orchestrator-finalas a new resource, but the Azure resource already exists (created byorchestrator-bootstrap). Theorchestrator-finalresource never makes it into the state.Code
Error messages
The
pulumi upcommand failed with the following message:Here is the detail of the stack after the error:
pulumi stack Current stack is example: Owner: laurent-laporte-pro-org Last updated: 1 minute ago (2026-03-03 18:41:24.392413 +0100 CET) Pulumi version used: v3.224.0 Current stack resources (5): TYPE NAME pulumi:pulumi:Stack so-containerapp-mi-group-example ├─ azure-native:app:ContainerApp orchestrator-bootstrap ├─ azuread:index/groupMember:GroupMember orchestrator-group-membership ├─ pulumi:providers:azure-native default_3_13_0 └─ pulumi:providers:azuread default_6_8_1 Current stack outputs (0): No output values currently in this stackWhat I've considered
Using a single
ContainerAppresource withdepends_onon aGroupMember— but I can't add the identity to the group before the app is created, and I can't configure ACR access before the identity has the role.Using
import/pulumi.ResourceOptions(import_=...)on the final resource — but this feels hacky and I'm not sure it's the right pattern.Questions
Is the two-
ContainerApp-resource pattern (bootstrap + final) the right approach, and if so, how do I tell Pulumi thatorchestrator-finalshould update the existing resource rather than try to create it?Alternatively, is there a cleaner Pulumi-native pattern to handle this kind of circular dependency (need the resource to exist to get its identity, need the identity to have a role before the resource can use it)?
Environment
pulumi: v3.224.0pulumi-azure-native: 3.13.0pulumi-azuread: 6.8.1Beta Was this translation helpful? Give feedback.
All reactions