I’ve painted myself into a corner with the manual ...
# azure
p
I’ve painted myself into a corner with the manual migration of existing resources to the native provider. I followed the instructions here https://www.pulumi.com/docs/intro/cloud-providers/azure/from-classic/ I only imported 3 resources: the resource group, an AppInsights account and a Cosmos DB account. The rest of my stack I’m happy for Pulumi to recreate. The imported resources were marked as protected (which is OK I guess). But when I do
pulumi up
it fails:
error: Preview failed: refusing to delete protected resource 'urn:pulumi:dev::SvcStacks::azure-native:resources:ResourceGroup::orgflow-stacks-dev-rg'
I can’t do
pulumi destroy
either:
Not quite sure why it would be trying to delete those resources on
update
They have the exact same resource names in the Pulumi program, the stack and in Azure
All I did was: 1. Migrate the code to the new native provider 2. Import these 3 resources 3. Attempt an
update
We do not use auto-naming of resources btw, instead we include the stack name in the resource names and specify them explicitly on all resources.
Any idea what’s going on anyone, and how I can get out of it?
It seems I somehow ended up with duplicate resources in the stack:
So it’s trying to both replace and delete them?
Not sure how this could happen?
Do I need to do the import before I migrate the code?
s
The docs recommend running the pulumi import commands as part of the migration step. Did you confirm the import?
p
Hi @sparse-park-68967 Not sure what you mean exactly here. I did run the import command, and confirmed it, for each of the 3 resources.
It completed successfully for each of them.
t
Have you added the code to you program? Why is it trying to delete them?
p
That’s what I’m wondering too - yes, the code changes I did first of all.
Changing no properties, just migrating to AzureNative
After that, imported these 3 resources, no problem
Then on
update
Pulumi decides they need to be replaced
Because of differences between “westeurope” and “WestEurope” it seems?
And in addition, the old resources are still in the stack also, and those are show for deletion in the preview
And they have the same name!
s
just to confirm, the azure classic version of the resource code is still there? alongside the native version emitted by the import command?
p
No - I changed the resource code from classic to native, as the first step
Manually
For the resource group for example, this only meant changing the namespace import basically.
Maybe I should clarify, here are the steps I performed: • Change the code from classic to native, keeping the same resource names and all other properties • Run
pulumi import
on these 3 resources - successfully • Run
pulumi up
• Preview fails because Pulumi thinks it needs to replace these 3 resources, but they are marked as protected by the import • Manually removed the protection from the stack using
stack export
and
stack import
to be able to preview • Run
pulumi preview
which shows my second screenshot above
s
I’d really recommend following the steps in the migration documentation - i.e. add the code for the native version along side, change references to the new version and then doing the state delete of the azure classic version along with the code.
p
Is that possible when not using auto-naming?
s
auto-naming refers to the name for the resource in azure during creation. In this case you are importing an existing resource which already has a name. Autonaming should have no part to play
p
Ah
I get it
I’ll try it
👍 1
s
I’d personally back all the way out to the original code with azure-classic then just add the code for the imported versions on native and make sure
pulumi up
is happy. Then follow the steps in migration guide (Migrate the resource group - steps 7 through 10)