If i add a provider to an azure-native stack that'...
# azure
w
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
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
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
yes
there may be a better way to do this, but I’m not aware of any
w
thanks for the help. trying it out on a small test project first.
b
@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
nice
w
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
I dont think so? what are you setting as options?