https://pulumi.com logo
Title
w

witty-airport-81009

10/21/2021, 10:25 AM
If i add a provider to an azure-native stack that's already been deployed before the provider was added Pulumi wants to replace resources instead of just updating them. For a lot of resources in the stack that's fine, but for others, like db's this is not optimal. Is there anything I can do to make Pulumi think these are still the same resources, and all it needs to do is update the provider? The provider was added as we moved some resources in a stack across to a different azure subscription, whilst others (e.g. dns zone) remained in the old subscription.
p

prehistoric-kite-30979

10/21/2021, 10:49 AM
We do this by manually editing the state
You just need to point the provider field of the resources you don’t want to be replaced to the new provider.
the format is
$SOME_STUFF::${providerName}::${providerID}
iirc
w

witty-airport-81009

10/21/2021, 10:56 AM
ok so what i'll probably need to do is pulumi up targetting just the new providers so they get ids, then reference them in the stack (export - edit - then import)?
p

prehistoric-kite-30979

10/21/2021, 12:00 PM
yes
there may be a better way to do this, but I’m not aware of any
w

witty-airport-81009

10/21/2021, 12:05 PM
thanks for the help. trying it out on a small test project first.
b

billowy-army-68599

10/21/2021, 3:13 PM
@witty-airport-81009 @prehistoric-kite-30979 you can use aliases for this: https://www.pulumi.com/blog/cumundi-guest-post/ The reason this happens is because when you update your pulumi resource with an explicit provider, it updates the urn. If you alias to the old resource, it should keep the same urn
🙌 1
p

prehistoric-kite-30979

10/21/2021, 3:16 PM
nice
w

witty-airport-81009

10/21/2021, 3:49 PM
oh that sounds super useful and potentially less error-prone. thanks for that
ok so i finally got round to trying this on Friday and couldn't get it to work. on researching it this morning am i right in thinking the following issue is related to this: • https://github.com/pulumi/pulumi/issues/7012 Think i'm going to have to do the stack export/edit/import workaround
p

prehistoric-kite-30979

11/08/2021, 12:00 PM
I dont think so? what are you setting as options?