labd / terraform-provider-commercetools

Terraform provider for commercetools
https://registry.terraform.io/providers/labd/commercetools/latest/docs
Mozilla Public License 2.0
64 stars 68 forks source link

CT project settings version mismatch #481

Closed randalvs closed 2 months ago

randalvs commented 4 months ago

Hi, We use the pulumi-commercetools provider which is a bridge to this Terraform provider.

One of the resources we provision are the project settings (Currency, Language, etc.). The provider checks to see if something needs to be updated in the project settings by comparing the state (in Pulumi) with the current state (in Commercetools). One of the properties stored in the state is the project settings version value.

There seem to be some background processes running internally at Commercetools that update the version number of the project settings. This was confirmed by Commercetools support. After this we encounter an issue because the state in Pulumi is out of sync with the current state in Commercetools. To be more precise the current version number of the project settings in Commercetools is higher than the version number stored in the state in Pulumi. As a consequence Pulumi provisioning fails. Since the Pulumi provider is nothing more than a wrapper around the Terraform provider we wonder if this is also an issue when using Terraform. Has anyone encountered this? Any suggestions, work arounds (other then manually adapting the state in Pulumi 😊) ?

Thanks in advance.

demeyerthom commented 4 months ago

Hi @randalvs ! I have no experience with Pulumi, so I am unsure what it does under the hood here.

In our own terraform provider implementation we first refresh the state in memory which actually updates the version number to the current one also, so generally I would not expect version mismatches to occur there.

However if Pulumi just looks at the shape of the data without doing this refresh-before-change that might be what causes the issue. Commercetools versions can change in state, so any tool that uses these versions to update stuff needs to check what the latest version in Commercetools is, instead of using the latest version it has seen... I guess this is something that needs to be solved in that provider.

Not exactly a helpful response 😅

randalvs commented 4 months ago

@demeyerthom, thanks for your reply.

I guess you're right and the way the terraform provider works differs from the way the Pulumi provider works. There is probably no refresh action in Pulumi. We're currently investigating the best way to solve this. I will update this issue again once we have a solution.