https://pulumi.com logo
Title
p

prehistoric-nail-50687

03/17/2021, 3:15 PM
I have question related to the migration of
@pulumi/azure-nextgen
to
@pulumi/azure-native
… If I have an import like
import * as operationalinsights from "@pulumi/azure-nextgen/operationalinsights/v20200801";
is it save to change it to the new version-less import:
import * as operationalinsights from "@pulumi/azure-native/operationalinsights";
or should I keep the version in the import?
t

tall-librarian-49374

03/17/2021, 3:25 PM
What do you mean by “safe”?
p

prehistoric-nail-50687

03/17/2021, 3:40 PM
will it change my existing resources? or is it better to keep the versions? whats the recomendation?
t

tall-librarian-49374

03/17/2021, 3:43 PM
You didn’t mention which resources you use. The versions are aliased, so it won’t need to re-create them from scratch. But if api versions don’t match, there may be differences in inputs/outputs.
You can first move to
native
without changing the version and then decide separately.
p

prehistoric-nail-50687

03/17/2021, 3:53 PM
well, there are many different resources… so If I understand you correctly: if it compiles then it should also not change the existing resources (e.g. WebApp, AppServicePlan, DiagnosticSetting, insights.Component, …).
so basically I’m a bit unsure whether I should stick with the versioned imports I have or if I should switch to version-less. Currently it looks like two Typsescript-API are fine/compatible (in my case at least)
t

tall-librarian-49374

03/17/2021, 3:57 PM
Unless your named versions are somehow old (very different from the version-less), you should be fine switching over.
Even if it compiles, you may see a diff when you run
pulumi up
(e.g. you updated to a version which has different defaults).
It’s hard to make blank statements that would be universal here
Another tradeoff: versionless resources may get breaking changes between 0.x and 0.(x+1) of the provider and 1.x and 2.x, for example.
p

prehistoric-nail-50687

03/17/2021, 4:00 PM
👍 thanks, that helps
Sorry to bother you again… reading about the migration, https://www.pulumi.com/blog/full-coverage-of-azure-resources-with-azure-native/#migrate-from-azure-nextgen-to-azure-native it says:
Run pulumi up and make sure the program ran successfully. The preview should show no changes.
In my case this is not the case, it seems to dismiss all exsiting resources and wants to recreate every single one 😞
t

tall-librarian-49374

03/17/2021, 4:16 PM
That doesn’t sound good. Do you use custom providers (passed through resource options)?
p

prehistoric-nail-50687

03/17/2021, 4:20 PM
I do something like a provisioner (based on https://github.com/pulumi/examples/blob/master/aws-ts-ec2-provisioners/provisioners/provisioner.ts) to execute some shell commands. But these are at the very end of the dependency graph. (e.g. once the WebApp is created, it will run a command to configure a CustomDomain (required because of circular dependencies in the azure API)
other then that I have many custom resources (e.g.
extends pulumi.ComponentResource
)
t

tall-librarian-49374

03/17/2021, 4:27 PM
If looks like resource hierachy changed? What should be the parent of the
CustomCloudflareDomain
resource?
I mean, it’s trying to delete
cloudflare:index:Record
which can’t be related to the migration nextgen->native
p

prehistoric-nail-50687

03/17/2021, 4:30 PM
hmm, here is the output of
pulumi stack
https://gist.github.com/imod/10daa9970217ea97b93382289592dca1#file-output-of-current-pulumi-stack - I need to dig into this more deeply I guess
I did also do an update of the cloudflare dependency - I’' revert that
t

tall-librarian-49374

03/17/2021, 4:33 PM
Ok, so you parented component resources to custom resources and now you update those custom resources to the new library and that doesn’t quite work. That’s an interesting scenario.
p

prehistoric-nail-50687

03/17/2021, 4:36 PM
is that something strange? I thought that would always be the case when using custom resources. would you not set the parent of the “real-resource” to the custom resource?
would you have expected that to work or am I doing something to exotic here?
t

tall-librarian-49374

03/17/2021, 4:38 PM
Side note: In our terms - “custom” = real, e.g. azure-native, and “component” is what you defined.
p

prehistoric-nail-50687

03/17/2021, 4:39 PM
ah ok, sorry - I’ll try to use the correct terms next time 🙂
I think all I’m doing with the whole parenting thing is what is described here: https://www.pulumi.com/docs/intro/concepts/resources/#creating-child-resources - I create custom resources inside the constructor of my component and set the component as the parent of the resource
{ parent: this }
t

tall-librarian-49374

03/17/2021, 7:38 PM
Yes, I’m not saying you are doing something illegal. Probably, worth filing an issue with a repro. The only workaround I can think of so far is start aliasing all resources manually to make sure the hierarchy holds.
p

prehistoric-nail-50687

03/17/2021, 11:25 PM
@tall-librarian-49374 I created an issue with a small example project: https://github.com/pulumi/pulumi-azure-native/issues/674
t

tall-librarian-49374

03/18/2021, 7:14 PM
Thank you. I think that, short-term, you should probably edit your state manually. Export it with
pulumi stack export
, back it up, then replace
azure-nextgen
with
azure-native
and import again. Crude but should work.
p

prehistoric-nail-50687

03/19/2021, 6:36 AM
thanks @tall-librarian-49374 I’ll try that!