Added an extra test for the Elasticache Cluster to show that updates work. Also added some debugging to show that the API returns the Elasticache retention period info
This commit is contained in:
parent
4f05df6cad
commit
707bfd739a
|
@ -287,7 +287,9 @@ func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{})
|
||||||
d.Set("security_group_ids", c.SecurityGroups)
|
d.Set("security_group_ids", c.SecurityGroups)
|
||||||
d.Set("parameter_group_name", c.CacheParameterGroup)
|
d.Set("parameter_group_name", c.CacheParameterGroup)
|
||||||
d.Set("maintenance_window", c.PreferredMaintenanceWindow)
|
d.Set("maintenance_window", c.PreferredMaintenanceWindow)
|
||||||
|
log.Printf("[INFO] Found %s as the Snapshow Window", *c.SnapshotWindow)
|
||||||
d.Set("snapshot_window", c.SnapshotWindow)
|
d.Set("snapshot_window", c.SnapshotWindow)
|
||||||
|
log.Printf("[INFO] Found %d as the Snapshow Retention Limit", *c.SnapshotRetentionLimit)
|
||||||
d.Set("snapshot_retention_limit", c.SnapshotRetentionLimit)
|
d.Set("snapshot_retention_limit", c.SnapshotRetentionLimit)
|
||||||
if c.NotificationConfiguration != nil {
|
if c.NotificationConfiguration != nil {
|
||||||
if *c.NotificationConfiguration.TopicStatus == "active" {
|
if *c.NotificationConfiguration.TopicStatus == "active" {
|
||||||
|
|
|
@ -54,6 +54,39 @@ func TestAccAWSElasticacheCluster_snapshots(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
func TestAccAWSElasticacheCluster_snapshotsWithUpdates(t *testing.T) {
|
||||||
|
var ec elasticache.CacheCluster
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckAWSElasticacheClusterDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccAWSElasticacheClusterConfig_snapshots,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckAWSElasticacheSecurityGroupExists("aws_elasticache_security_group.bar"),
|
||||||
|
testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar", &ec),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_elasticache_cluster.bar", "snapshot_window", "05:00-09:00"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_elasticache_cluster.bar", "snapshot_retention_limit", "3"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccAWSElasticacheClusterConfig_snapshotsUpdated,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckAWSElasticacheSecurityGroupExists("aws_elasticache_security_group.bar"),
|
||||||
|
testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar", &ec),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_elasticache_cluster.bar", "snapshot_window", "07:00-09:00"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_elasticache_cluster.bar", "snapshot_retention_limit", "7"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestAccAWSElasticacheCluster_vpc(t *testing.T) {
|
func TestAccAWSElasticacheCluster_vpc(t *testing.T) {
|
||||||
var csg elasticache.CacheSubnetGroup
|
var csg elasticache.CacheSubnetGroup
|
||||||
|
@ -210,6 +243,40 @@ resource "aws_elasticache_cluster" "bar" {
|
||||||
}
|
}
|
||||||
`, genRandInt(), genRandInt(), genRandInt())
|
`, genRandInt(), genRandInt(), genRandInt())
|
||||||
|
|
||||||
|
var testAccAWSElasticacheClusterConfig_snapshotsUpdated = fmt.Sprintf(`
|
||||||
|
provider "aws" {
|
||||||
|
region = "us-east-1"
|
||||||
|
}
|
||||||
|
resource "aws_security_group" "bar" {
|
||||||
|
name = "tf-test-security-group-%03d"
|
||||||
|
description = "tf-test-security-group-descr"
|
||||||
|
ingress {
|
||||||
|
from_port = -1
|
||||||
|
to_port = -1
|
||||||
|
protocol = "icmp"
|
||||||
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_elasticache_security_group" "bar" {
|
||||||
|
name = "tf-test-security-group-%03d"
|
||||||
|
description = "tf-test-security-group-descr"
|
||||||
|
security_group_names = ["${aws_security_group.bar.name}"]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_elasticache_cluster" "bar" {
|
||||||
|
cluster_id = "tf-test-%03d"
|
||||||
|
engine = "redis"
|
||||||
|
node_type = "cache.m1.small"
|
||||||
|
num_cache_nodes = 1
|
||||||
|
port = 6379
|
||||||
|
parameter_group_name = "default.redis2.8"
|
||||||
|
security_group_names = ["${aws_elasticache_security_group.bar.name}"]
|
||||||
|
snapshot_window = "07:00-09:00"
|
||||||
|
snapshot_retention_limit = 7
|
||||||
|
}
|
||||||
|
`, genRandInt(), genRandInt(), genRandInt())
|
||||||
|
|
||||||
var testAccAWSElasticacheClusterInVPCConfig = fmt.Sprintf(`
|
var testAccAWSElasticacheClusterInVPCConfig = fmt.Sprintf(`
|
||||||
resource "aws_vpc" "foo" {
|
resource "aws_vpc" "foo" {
|
||||||
cidr_block = "192.168.0.0/16"
|
cidr_block = "192.168.0.0/16"
|
||||||
|
|
Loading…
Reference in New Issue