From e24b69c45e37e76481dded474a98cb862e8518f6 Mon Sep 17 00:00:00 2001 From: Ivan Savciuc Date: Wed, 27 Dec 2023 14:22:36 +0200 Subject: [PATCH] fix(service): v3 to v4 migration cloud_name field (#1494) --- CHANGELOG.md | 1 + internal/schemautil/service.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b454a25f9..bf82b9d34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ nav_order: 1 - Add support for the `aiven_organization_user_group_member` resource, allowing the association of groups with the users. Please note that this resource is in the beta stage, and to use it, you would need to set the environment variable PROVIDER_AIVEN_ENABLE_BETA to a non-zero value. - Retry kafka topic creation error `Cluster only has N broker(s), cannot set replication factor to M` - Fix Kafka Topic migration issues from V3 to V4. +- Fix V3 to V4 migration issue related to cloud_name diff. ## [4.9.4] - 2023-12-13 diff --git a/internal/schemautil/service.go b/internal/schemautil/service.go index 13cc51940..cd2f2d011 100644 --- a/internal/schemautil/service.go +++ b/internal/schemautil/service.go @@ -67,6 +67,14 @@ func ServiceCommonSchema() map[string]*schema.Schema { Type: schema.TypeString, Optional: true, Description: "Defines where the cloud provider and region where the service is hosted in. This can be changed freely after service is created. Changing the value will trigger a potentially lengthy migration process for the service. Format is cloud provider name (`aws`, `azure`, `do` `google`, `upcloud`, etc.), dash, and the cloud provider specific region name. These are documented on each Cloud provider's own support articles, like [here for Google](https://cloud.google.com/compute/docs/regions-zones/) and [here for AWS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html).", + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + // This is a workaround for a bug when migrating from V3 to V4 Aiven Provider. + // The bug is that the cloud_name is not set in the state file, but it is set + // on the API side. This causes a diff during plan, and it will not disappear + // even after consequent applies. This is because the state is not updated + // with the cloud_name value. + return new == "" + }, }, "plan": { Type: schema.TypeString,