From 15b9bde1fee0cdae5a88c824e9d4df6257fdf550 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Tue, 28 Apr 2015 11:30:15 -0500 Subject: [PATCH] providers/aws: add _cluster to aws_elasticache This AWS calls the actual resources "Cache Clusters" so it seems like this name makes more sense. Verified all Elasticache acc tests pass. --- builtin/providers/aws/provider.go | 2 +- ...go => resource_aws_elasticache_cluster.go} | 14 +++--- ... resource_aws_elasticache_cluster_test.go} | 46 +++++++++++-------- 3 files changed, 36 insertions(+), 26 deletions(-) rename builtin/providers/aws/{resource_aws_elasticache.go => resource_aws_elasticache_cluster.go} (93%) rename builtin/providers/aws/{resource_aws_elasticache_test.go => resource_aws_elasticache_cluster_test.go} (77%) diff --git a/builtin/providers/aws/provider.go b/builtin/providers/aws/provider.go index 9efc95a04..3080df866 100644 --- a/builtin/providers/aws/provider.go +++ b/builtin/providers/aws/provider.go @@ -83,7 +83,7 @@ func Provider() terraform.ResourceProvider { "aws_db_security_group": resourceAwsDbSecurityGroup(), "aws_db_subnet_group": resourceAwsDbSubnetGroup(), "aws_ebs_volume": resourceAwsEbsVolume(), - "aws_elasticache": resourceAwsElasticache(), + "aws_elasticache_cluster": resourceAwsElasticacheCluster(), "aws_elasticache_subnet_group": resourceAwsElasticacheSubnetGroup(), "aws_elasticache_security_group": resourceAwsElasticacheSecurityGroup(), "aws_eip": resourceAwsEip(), diff --git a/builtin/providers/aws/resource_aws_elasticache.go b/builtin/providers/aws/resource_aws_elasticache_cluster.go similarity index 93% rename from builtin/providers/aws/resource_aws_elasticache.go rename to builtin/providers/aws/resource_aws_elasticache_cluster.go index 6d691c91a..dfff36217 100644 --- a/builtin/providers/aws/resource_aws_elasticache.go +++ b/builtin/providers/aws/resource_aws_elasticache_cluster.go @@ -12,11 +12,11 @@ import ( "github.com/hashicorp/terraform/helper/schema" ) -func resourceAwsElasticache() *schema.Resource { +func resourceAwsElasticacheCluster() *schema.Resource { return &schema.Resource{ - Create: resourceAwsElasticacheCreate, - Read: resourceAwsElasticacheRead, - Delete: resourceAwsElasticacheDelete, + Create: resourceAwsElasticacheClusterCreate, + Read: resourceAwsElasticacheClusterRead, + Delete: resourceAwsElasticacheClusterDelete, Schema: map[string]*schema.Schema{ "cluster_id": &schema.Schema{ @@ -84,7 +84,7 @@ func resourceAwsElasticache() *schema.Resource { } } -func resourceAwsElasticacheCreate(d *schema.ResourceData, meta interface{}) error { +func resourceAwsElasticacheClusterCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).elasticacheconn clusterId := d.Get("cluster_id").(string) @@ -140,7 +140,7 @@ func resourceAwsElasticacheCreate(d *schema.ResourceData, meta interface{}) erro return nil } -func resourceAwsElasticacheRead(d *schema.ResourceData, meta interface{}) error { +func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).elasticacheconn req := &elasticache.DescribeCacheClustersInput{ CacheClusterID: aws.String(d.Id()), @@ -170,7 +170,7 @@ func resourceAwsElasticacheRead(d *schema.ResourceData, meta interface{}) error return nil } -func resourceAwsElasticacheDelete(d *schema.ResourceData, meta interface{}) error { +func resourceAwsElasticacheClusterDelete(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).elasticacheconn req := &elasticache.DeleteCacheClusterInput{ diff --git a/builtin/providers/aws/resource_aws_elasticache_test.go b/builtin/providers/aws/resource_aws_elasticache_cluster_test.go similarity index 77% rename from builtin/providers/aws/resource_aws_elasticache_test.go rename to builtin/providers/aws/resource_aws_elasticache_cluster_test.go index 567b4be8b..d0a782d80 100644 --- a/builtin/providers/aws/resource_aws_elasticache_test.go +++ b/builtin/providers/aws/resource_aws_elasticache_cluster_test.go @@ -12,35 +12,45 @@ import ( "github.com/hashicorp/terraform/terraform" ) -func TestAccAWSElasticache(t *testing.T) { +func TestAccAWSElasticacheCluster(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testAccCheckAWSElasticacheDestroy, + CheckDestroy: testAccCheckAWSElasticacheClusterDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAWSElasticacheConfig, + Config: testAccAWSElasticacheClusterConfig, Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcacheSecurityGroupExists("aws_elasticache_security_group.bar"), - testAccCheckAWSElasticacheExists("aws_elasticache.bar"), - ), - }, - resource.TestStep{ - Config: testAccAWSElasticacheInVPCConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSEcacheSubnetGroupExists("aws_elasticache_subnet_group.bar"), - testAccCheckAWSElasticacheExists("aws_elasticache.bar"), + testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar"), ), }, }, }) } -func testAccCheckAWSElasticacheDestroy(s *terraform.State) error { +func TestAccAWSElasticacheCluster_vpc(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSElasticacheClusterDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSElasticacheClusterInVPCConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEcacheSubnetGroupExists("aws_elasticache_subnet_group.bar"), + testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar"), + ), + }, + }, + }) +} + +func testAccCheckAWSElasticacheClusterDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).elasticacheconn for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_elasticache" { + if rs.Type != "aws_elasticache_cluster" { continue } res, err := conn.DescribeCacheClusters(&elasticache.DescribeCacheClustersInput{ @@ -56,7 +66,7 @@ func testAccCheckAWSElasticacheDestroy(s *terraform.State) error { return nil } -func testAccCheckAWSElasticacheExists(n string) resource.TestCheckFunc { +func testAccCheckAWSElasticacheClusterExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] if !ok { @@ -82,7 +92,7 @@ func genRandInt() int { return rand.New(rand.NewSource(time.Now().UnixNano())).Int() % 1000 } -var testAccAWSElasticacheConfig = fmt.Sprintf(` +var testAccAWSElasticacheClusterConfig = fmt.Sprintf(` resource "aws_security_group" "bar" { name = "tf-test-security-group-%03d" description = "tf-test-security-group-descr" @@ -100,7 +110,7 @@ resource "aws_elasticache_security_group" "bar" { security_group_names = ["${aws_security_group.bar.name}"] } -resource "aws_elasticache" "bar" { +resource "aws_elasticache_cluster" "bar" { cluster_id = "tf-test-%03d" engine = "memcached" node_type = "cache.m1.small" @@ -110,7 +120,7 @@ resource "aws_elasticache" "bar" { } `, genRandInt(), genRandInt(), genRandInt()) -var testAccAWSElasticacheInVPCConfig = fmt.Sprintf(` +var testAccAWSElasticacheClusterInVPCConfig = fmt.Sprintf(` resource "aws_vpc" "foo" { cidr_block = "192.168.0.0/16" tags { @@ -145,7 +155,7 @@ resource "aws_security_group" "bar" { } } -resource "aws_elasticache" "bar" { +resource "aws_elasticache_cluster" "bar" { cluster_id = "tf-test-%03d" node_type = "cache.m1.small" num_cache_nodes = 1