Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_elasticache_cluster: Allow availability_zone to be specified with replication_group_id #5585

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion aws/resource_aws_elasticache_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ func resourceAwsElasticacheCluster() *schema.Resource {
Optional: true,
ForceNew: true,
ConflictsWith: []string{
"availability_zone",
"availability_zones",
"az_mode",
"engine_version",
Expand Down
56 changes: 52 additions & 4 deletions aws/resource_aws_elasticache_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,6 @@ func TestAccAWSElasticacheCluster_ReplicationGroupID_InvalidAttributes(t *testin
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSElasticacheClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSElasticacheClusterConfig_ReplicationGroupID_InvalidAttribute(rName, "availability_zone", "us-east-1a"),
ExpectError: regexp.MustCompile(`"replication_group_id": conflicts with availability_zone`),
},
{
Config: testAccAWSElasticacheClusterConfig_ReplicationGroupID_InvalidAttribute(rName, "availability_zones", "${list(\"us-east-1a\", \"us-east-1c\")}"),
ExpectError: regexp.MustCompile(`"replication_group_id": conflicts with availability_zones`),
Expand Down Expand Up @@ -728,6 +724,34 @@ func TestAccAWSElasticacheCluster_ReplicationGroupID_InvalidAttributes(t *testin
})
}

func TestAccAWSElasticacheCluster_ReplicationGroupID_AvailabilityZone_Ec2Classic(t *testing.T) {
oldvar := os.Getenv("AWS_DEFAULT_REGION")
os.Setenv("AWS_DEFAULT_REGION", "us-east-1")
defer os.Setenv("AWS_DEFAULT_REGION", oldvar)

var cluster elasticache.CacheCluster
var replicationGroup elasticache.ReplicationGroup
rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(7))
clusterResourceName := "aws_elasticache_cluster.replica"
replicationGroupResourceName := "aws_elasticache_replication_group.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccEC2ClassicPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSElasticacheClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSElasticacheClusterConfig_ReplicationGroupID_AvailabilityZone_Ec2Classic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSElasticacheReplicationGroupExists(replicationGroupResourceName, &replicationGroup),
testAccCheckAWSElasticacheClusterExists(clusterResourceName, &cluster),
testAccCheckAWSElasticacheClusterReplicationGroupIDAttribute(&cluster, &replicationGroup),
),
},
},
})
}

func TestAccAWSElasticacheCluster_ReplicationGroupID_SingleReplica_Ec2Classic(t *testing.T) {
oldvar := os.Getenv("AWS_DEFAULT_REGION")
os.Setenv("AWS_DEFAULT_REGION", "us-east-1")
Expand Down Expand Up @@ -1303,6 +1327,30 @@ resource "aws_elasticache_cluster" "replica" {
`, rName, attrName, attrValue)
}

func testAccAWSElasticacheClusterConfig_ReplicationGroupID_AvailabilityZone_Ec2Classic(rName string) string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {}

resource "aws_elasticache_replication_group" "test" {
replication_group_description = "Terraform Acceptance Testing"
replication_group_id = "%[1]s"
node_type = "cache.m3.medium"
number_cache_clusters = 1
port = 6379

lifecycle {
ignore_changes = ["number_cache_clusters"]
}
}

resource "aws_elasticache_cluster" "replica" {
availability_zone = "${data.aws_availability_zones.available.names[0]}"
cluster_id = "%[1]s1"
replication_group_id = "${aws_elasticache_replication_group.test.id}"
}
`, rName)
}

func testAccAWSElasticacheClusterConfig_ReplicationGroupID_Replica_Ec2Classic(rName string, count int) string {
return fmt.Sprintf(`
resource "aws_elasticache_replication_group" "test" {
Expand Down