From 750f770b0fbcf3a23d03d5b7e6d51dbeba9b0c58 Mon Sep 17 00:00:00 2001 From: digna-ionos Date: Thu, 12 Sep 2024 19:45:39 +0300 Subject: [PATCH] call ApplyTFConversions in Update function from terraform plugin sdk external client because it was causing unmarshalling errors. Signed-off-by: digna-ionos --- pkg/controller/external_tfpluginsdk.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/controller/external_tfpluginsdk.go b/pkg/controller/external_tfpluginsdk.go index 8fed8acd..a719bf0f 100644 --- a/pkg/controller/external_tfpluginsdk.go +++ b/pkg/controller/external_tfpluginsdk.go @@ -696,6 +696,11 @@ func (n *terraformPluginSDKExternal) Update(ctx context.Context, mg xpresource.M return managed.ExternalUpdate{}, err } + stateValueMap, err = n.config.ApplyTFConversions(stateValueMap, config.FromTerraform) + if err != nil { + return managed.ExternalUpdate{}, errors.Wrap(err, "cannot convert the singleton lists for the updated resource state value map into embedded objects") + } + err = mg.(resource.Terraformed).SetObservation(stateValueMap) if err != nil { return managed.ExternalUpdate{}, errors.Errorf("failed to set observation: %v", err)