Hi, I have following problem with Pulumi: Last y...
# azure
s
Hi, I have following problem with Pulumi: Last year I created a database account using API V20221115 since I needed few properties which were available only in this API, now I want to upgrade to the latest provider, but the problem is that the object ids in the Pulumi state contains the API versions like:
urn:pulumi:dev::azure-native:documentdb/v20221115:DatabaseAccount::cosmosdb
If I switch the API to latest the URN of the object is changed to the
urn:pulumi:dev::azure-native:documentdb/DatabaseAccount::cosmosdb
which results that Pulumi wants to drop and recreate my database which I don't want 🙂 ( of course object is protected so the drop fails ) . What is the best approach in this situation? Maybe I can manually rename the urn without dropping the database or do a backup, recreate and then restore of the data ?
t
Hmm, in theory, this should not happen since we have aliases between same resources of different API versions
Any chance you are changing anything else in addition to the API version? Maybe resource parent or name?
You can use the
aliases
resource option to point the new resource to the old urn, which should get you unblocked: https://www.pulumi.com/docs/concepts/options/aliases/ But again, this should not be required...
s
Thanks I will try and write back.
So from the logs it looks like the provider is changed since I'm switching from Pulumi.AzureNative v1 to v2
Copy code
12:42:08 [DBG] azure-native:documentdb:DatabaseAccount cosmosdb  [diff: ~provider]
12:42:08 [DBG] azure-native:documentdb:SqlResourceSqlRoleDefinition cosmosdb/79e77441-c1be-4ebb-b79e-ba50a15150a4  [diff: ~provider]
12:42:08 [DBG] azure-native:documentdb:SqlResourceSqlDatabase cosmosdb/Database  [diff: ~provider]
which results to try to drop from source perspective the change is
Copy code
- using Pulumi.AzureNative.DocumentDB.V20221115;
- using Pulumi.AzureNative.DocumentDB.V20221115.Inputs;
+ using Pulumi.AzureNative.DocumentDB;
+ using Pulumi.AzureNative.DocumentDB.Inputs;
I will try to set aliases to the resources and write if it is working.
So setting Aliases property worked. Thanks a lot.
r
hi guys, I seem to have the same problem (as I've also moved from AzureNative 1.* to 2.* but with Network peerings. tried to add the alias but no luck, probably not doing it right? any help you can provide?
seems to happen on refresh only..
t
@rhythmic-activity-46295 Any reason you are using that specific
v20210201
version? It was probably removed from v2 to save space, but any later version of the default one should work.
r
we were using it back in 2022 as it did have what we needed at the time, and trying to upgrade it now.. using the default.
this seems to happen on refresh only. we do a refresh on our pipelines before preview and update... locally can run preview and probably update without issues..
the stack json shows this:
t
I'm not sure how it can work on preview/update if the resource type doesn't exist anymore... My expectation is that your program should fail to compile.
r
preview works...
as it probably does not refer back to what is setup in the stack but rather uses the newer azurenative assembly as guide?!
the refresh has to look back to what's in the stack I take?!
not sure if the update would fail to be honest as I've not tried it yet...
this is what I get in detail when trying to do pulumi up:
t
Ah, so you updated your code but haven't run
up
yet. I'm not sure what is going on with refresh, but if you run
up
once it should update the versions in state and fix the refresh.
r
that is what I suspect but is kind of a catch 22. insofar as I run refresh in the pipeline before preview or up..
will skip the refresh and see how it goes