Skip to content

Commit 919aeb6

Browse files
authored
Merge pull request #31886 from LironEr/b-aws_redshift_cluster-fix-availability_zone_relocation_enabled
fix: Redshift cluster relocation enabled and publicly accessible can both be true
2 parents e1f2849 + a4e3c7a commit 919aeb6

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

.changelog/31886.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
resource/aws_redshift_cluster: Allow `availability_zone_relocation_enabled` to be `true` when `publicly_accessible` is `true`
3+
```

internal/service/redshift/cluster.go

-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package redshift
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
"log"
87
"regexp"
@@ -363,12 +362,6 @@ func ResourceCluster() *schema.Resource {
363362

364363
CustomizeDiff: customdiff.All(
365364
verify.SetTagsDiff,
366-
func(_ context.Context, diff *schema.ResourceDiff, v interface{}) error {
367-
if diff.Get("availability_zone_relocation_enabled").(bool) && diff.Get("publicly_accessible").(bool) {
368-
return errors.New("`availability_zone_relocation_enabled` cannot be true when `publicly_accessible` is true")
369-
}
370-
return nil
371-
},
372365
func(_ context.Context, diff *schema.ResourceDiff, v interface{}) error {
373366
if diff.Id() == "" {
374367
return nil

internal/service/redshift/cluster_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ func TestAccRedshiftCluster_availabilityZoneRelocation(t *testing.T) {
740740

741741
func TestAccRedshiftCluster_availabilityZoneRelocation_publiclyAccessible(t *testing.T) {
742742
ctx := acctest.Context(t)
743+
var v redshift.Cluster
744+
resourceName := "aws_redshift_cluster.test"
743745
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
744746

745747
resource.ParallelTest(t, resource.TestCase{
@@ -749,8 +751,12 @@ func TestAccRedshiftCluster_availabilityZoneRelocation_publiclyAccessible(t *tes
749751
CheckDestroy: testAccCheckClusterDestroy(ctx),
750752
Steps: []resource.TestStep{
751753
{
752-
Config: testAccClusterConfig_availabilityZoneRelocationPubliclyAccessible(rName),
753-
ExpectError: regexp.MustCompile("`availability_zone_relocation_enabled` cannot be true when `publicly_accessible` is true"),
754+
Config: testAccClusterConfig_availabilityZoneRelocationPubliclyAccessible(rName),
755+
Check: resource.ComposeTestCheckFunc(
756+
testAccCheckClusterExists(ctx, resourceName, &v),
757+
resource.TestCheckResourceAttr(resourceName, "availability_zone_relocation_enabled", "true"),
758+
resource.TestCheckResourceAttr(resourceName, "publicly_accessible", "true"),
759+
),
754760
},
755761
},
756762
})

0 commit comments

Comments
 (0)