UpgradeState from SDKv2 to Framework

Is it possible to use UpgradeState for upgrading SDKv2 schema to Framework schema?
If so, can it be assumed that the SDKv2 schema needs to be reconfigured to the Framework schema in the PriorSchema field?

Hi @OrNovo :wave:

I’m sure you’ve already seen the documentation for migrating from SDKv2 to the Framework, but just in case the multiple steps that need to be undertaken are described in the Migrating from SDK guide.

In the case of migrating the schema from SDKv2 to the Framework, the Schema section of the migration guide along with the linked sections to information regarding attributes and blocks should hopefully prove useful.

Within the migration guide there is also a section on migrating state upgraders from SDKv2 to the Framework which along with the information on State Upgrade should help to clarify how state upgraders should be configured within the Framework.

So if your question is should UpgradeState be used for migrating an SDKv2 schema to a Framework schema then the answer is no. The steps for migrating the schema are as outlined in the Schema section of the migration guide.

So if I understand it correctly, I first need to implement the same schema from SDKv2 with Framework (which can be done without breaking changes), and then implement the upgrading phase in the Framework using UpgradeState.

Yes. You will need to:

Can you expand a little on your use-case for UpgradeState()? Is it purely for implementing StateUpgraders from SDKv2 in the Framework?

I currently don’t implement StateUpgraders in the SDKv2 provider and I also didn’t fill the Version field for that resource.
I want to upgrade from SDKv2 to Framework, but because Framework schema have more capabilities I also want to change the resource schema.
Therefore I want to provide a simple way to upgrade existing resource to the new schema.

For additional context, @OrNovo has, in other topics in this forum, been investigating migrating from nested blocks to attributes concurrently with moving from SDKv2 to Framework, and potentially replacing sets with maps as well.

1 Like

Thanks for the additional context @maxb. In that case, you can use implementation(s) of UpgradeState() to modify the schema. This is described in the State Upgrade section of the docs.

1 Like

@bendbennett In a case I want to stay with the same schema and only migrate from SDKv2 to Framework - do you know maybe if there is some helper function for transform SDKv2 resource schema to Framework schema? because it seems like an automated process.

Whilst the process may be partially automatable, to my knowledge, no-one has automated it.

It appears to be assumed that there is enough translation between different ways of doing things, that a human mind will mostly be required to make case-by-case decisions.

1 Like

As @maxb mentioned, migrating a schema from SDKv2 to the framework is currently a manual process. Hopefully the migration guide will provide the necessary guidance for this process and if you have specific questions that are not covered by the guide then you can reach out on this forum to ask further questions.