From e90c4f0c23c3da574610105333ae99cdedc6d85f Mon Sep 17 00:00:00 2001 From: LironEr Date: Sat, 10 Jun 2023 10:50:05 +0300 Subject: [PATCH 1/2] fix: Redshift cluster relocation enabled and publicly accessible can both be true --- .changelog/31886.txt | 3 +++ internal/service/redshift/cluster.go | 7 ------- internal/service/redshift/cluster_test.go | 10 ++++++++-- 3 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 .changelog/31886.txt diff --git a/.changelog/31886.txt b/.changelog/31886.txt new file mode 100644 index 00000000000..a93e8c144a3 --- /dev/null +++ b/.changelog/31886.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_redshift_cluster: allow `availability_zone_relocation_enabled` to be true when `publicly_accessible` is true +``` \ No newline at end of file diff --git a/internal/service/redshift/cluster.go b/internal/service/redshift/cluster.go index 5d3537dd5c6..9a130774116 100644 --- a/internal/service/redshift/cluster.go +++ b/internal/service/redshift/cluster.go @@ -2,7 +2,6 @@ package redshift import ( "context" - "errors" "fmt" "log" "regexp" @@ -363,12 +362,6 @@ func ResourceCluster() *schema.Resource { CustomizeDiff: customdiff.All( verify.SetTagsDiff, - func(_ context.Context, diff *schema.ResourceDiff, v interface{}) error { - if diff.Get("availability_zone_relocation_enabled").(bool) && diff.Get("publicly_accessible").(bool) { - return errors.New("`availability_zone_relocation_enabled` cannot be true when `publicly_accessible` is true") - } - return nil - }, func(_ context.Context, diff *schema.ResourceDiff, v interface{}) error { if diff.Id() == "" { return nil diff --git a/internal/service/redshift/cluster_test.go b/internal/service/redshift/cluster_test.go index 09cea46c91d..3bf6118b2b6 100644 --- a/internal/service/redshift/cluster_test.go +++ b/internal/service/redshift/cluster_test.go @@ -740,6 +740,8 @@ func TestAccRedshiftCluster_availabilityZoneRelocation(t *testing.T) { func TestAccRedshiftCluster_availabilityZoneRelocation_publiclyAccessible(t *testing.T) { ctx := acctest.Context(t) + var v redshift.Cluster + resourceName := "aws_redshift_cluster.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ @@ -749,8 +751,12 @@ func TestAccRedshiftCluster_availabilityZoneRelocation_publiclyAccessible(t *tes CheckDestroy: testAccCheckClusterDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccClusterConfig_availabilityZoneRelocationPubliclyAccessible(rName), - ExpectError: regexp.MustCompile("`availability_zone_relocation_enabled` cannot be true when `publicly_accessible` is true"), + Config: testAccClusterConfig_availabilityZoneRelocationPubliclyAccessible(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckClusterExists(ctx, resourceName, &v), + resource.TestCheckResourceAttr(resourceName, "availability_zone_relocation_enabled", "true"), + resource.TestCheckResourceAttr(resourceName, "publicly_accessible", "true"), + ), }, }, }) From a4e3c7ad5c9d6e0f62f0f4f68792c945a34182dc Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 10 Jun 2023 17:27:39 -0400 Subject: [PATCH 2/2] Tweak CHANGELOG entry --- .changelog/31886.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changelog/31886.txt b/.changelog/31886.txt index a93e8c144a3..dc929d42934 100644 --- a/.changelog/31886.txt +++ b/.changelog/31886.txt @@ -1,3 +1,3 @@ ```release-note:bug -resource/aws_redshift_cluster: allow `availability_zone_relocation_enabled` to be true when `publicly_accessible` is true -``` \ No newline at end of file +resource/aws_redshift_cluster: Allow `availability_zone_relocation_enabled` to be `true` when `publicly_accessible` is `true` +```