From 9a1ae44475de761aa3d2df671acf4283a3e29bc7 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Fri, 29 May 2015 09:40:34 -0500 Subject: [PATCH] provider/aws: Cleanups on Kinesis naming --- .../aws/resource_aws_kinesis_stream.go | 19 +++++++++---------- .../aws/resource_aws_kinesis_stream_test.go | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/builtin/providers/aws/resource_aws_kinesis_stream.go b/builtin/providers/aws/resource_aws_kinesis_stream.go index 2485edb28..ea01d7b16 100644 --- a/builtin/providers/aws/resource_aws_kinesis_stream.go +++ b/builtin/providers/aws/resource_aws_kinesis_stream.go @@ -55,9 +55,6 @@ func resourceAwsKinesisStreamCreate(d *schema.ResourceData, meta interface{}) er return err } - // set name as ID for now. Kinesis stream names are unique per account+region - d.SetId(sn) - stateConf := &resource.StateChangeConf{ Pending: []string{"CREATING"}, Target: "ACTIVE", @@ -75,7 +72,8 @@ func resourceAwsKinesisStreamCreate(d *schema.ResourceData, meta interface{}) er } s := streamRaw.(*kinesis.StreamDescription) - d.Set("arn", *s.StreamARN) + d.SetId(*s.StreamARN) + d.Set("arn", s.StreamARN) return nil } @@ -83,7 +81,7 @@ func resourceAwsKinesisStreamCreate(d *schema.ResourceData, meta interface{}) er func resourceAwsKinesisStreamRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).kinesisconn describeOpts := &kinesis.DescribeStreamInput{ - StreamName: aws.String(d.Id()), + StreamName: aws.String(d.Get("name").(string)), Limit: aws.Long(1), } resp, err := conn.DescribeStream(describeOpts) @@ -107,8 +105,9 @@ func resourceAwsKinesisStreamRead(d *schema.ResourceData, meta interface{}) erro func resourceAwsKinesisStreamDelete(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).kinesisconn + sn := d.Get("name").(string) _, err := conn.DeleteStream(&kinesis.DeleteStreamInput{ - StreamName: aws.String(d.Id()), + StreamName: aws.String(sn), }) if err != nil { @@ -118,7 +117,7 @@ func resourceAwsKinesisStreamDelete(d *schema.ResourceData, meta interface{}) er stateConf := &resource.StateChangeConf{ Pending: []string{"DELETING"}, Target: "DESTROYED", - Refresh: streamStateRefreshFunc(conn, d.Id()), + Refresh: streamStateRefreshFunc(conn, sn), Timeout: 5 * time.Minute, Delay: 10 * time.Second, MinTimeout: 3 * time.Second, @@ -128,17 +127,17 @@ func resourceAwsKinesisStreamDelete(d *schema.ResourceData, meta interface{}) er if err != nil { return fmt.Errorf( "Error waiting for Stream (%s) to be destroyed: %s", - d.Id(), err) + sn, err) } d.SetId("") return nil } -func streamStateRefreshFunc(conn *kinesis.Kinesis, streamName string) resource.StateRefreshFunc { +func streamStateRefreshFunc(conn *kinesis.Kinesis, sn string) resource.StateRefreshFunc { return func() (interface{}, string, error) { describeOpts := &kinesis.DescribeStreamInput{ - StreamName: aws.String(streamName), + StreamName: aws.String(sn), Limit: aws.Long(1), } resp, err := conn.DescribeStream(describeOpts) diff --git a/builtin/providers/aws/resource_aws_kinesis_stream_test.go b/builtin/providers/aws/resource_aws_kinesis_stream_test.go index 7de318f27..8a265577f 100644 --- a/builtin/providers/aws/resource_aws_kinesis_stream_test.go +++ b/builtin/providers/aws/resource_aws_kinesis_stream_test.go @@ -45,7 +45,7 @@ func testAccCheckKinesisStreamExists(n string, stream *kinesis.StreamDescription conn := testAccProvider.Meta().(*AWSClient).kinesisconn describeOpts := &kinesis.DescribeStreamInput{ - StreamName: aws.String(rs.Primary.ID), + StreamName: aws.String(rs.Primary.Attributes["name"]), Limit: aws.Long(1), } resp, err := conn.DescribeStream(describeOpts) @@ -83,7 +83,7 @@ func testAccCheckKinesisStreamDestroy(s *terraform.State) error { } conn := testAccProvider.Meta().(*AWSClient).kinesisconn describeOpts := &kinesis.DescribeStreamInput{ - StreamName: aws.String(rs.Primary.ID), + StreamName: aws.String(rs.Primary.Attributes["name"]), Limit: aws.Long(1), } resp, err := conn.DescribeStream(describeOpts)