Skip to content

Commit

Permalink
Merge pull request #31886 from LironEr/b-aws_redshift_cluster-fix-ava…
Browse files Browse the repository at this point in the history
…ilability_zone_relocation_enabled

fix: Redshift cluster relocation enabled and publicly accessible can both be true
  • Loading branch information
ewbankkit authored Jun 12, 2023
2 parents e1f2849 + a4e3c7a commit 919aeb6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .changelog/31886.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_redshift_cluster: Allow `availability_zone_relocation_enabled` to be `true` when `publicly_accessible` is `true`
```
7 changes: 0 additions & 7 deletions internal/service/redshift/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package redshift

import (
"context"
"errors"
"fmt"
"log"
"regexp"
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions internal/service/redshift/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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"),
),
},
},
})
Expand Down

0 comments on commit 919aeb6

Please sign in to comment.