Merge pull request #2986 from tphummel/aws_kinesis_stream-shard_count

aws_kinesis_stream: shard_count state fix
This commit is contained in:
Clint 2015-08-31 09:43:40 -05:00
commit 03aba6f6a3
2 changed files with 6 additions and 5 deletions

View File

@ -82,7 +82,6 @@ func resourceAwsKinesisStreamRead(d *schema.ResourceData, meta interface{}) erro
conn := meta.(*AWSClient).kinesisconn conn := meta.(*AWSClient).kinesisconn
describeOpts := &kinesis.DescribeStreamInput{ describeOpts := &kinesis.DescribeStreamInput{
StreamName: aws.String(d.Get("name").(string)), StreamName: aws.String(d.Get("name").(string)),
Limit: aws.Int64(1),
} }
resp, err := conn.DescribeStream(describeOpts) resp, err := conn.DescribeStream(describeOpts)
if err != nil { if err != nil {
@ -138,7 +137,6 @@ func streamStateRefreshFunc(conn *kinesis.Kinesis, sn string) resource.StateRefr
return func() (interface{}, string, error) { return func() (interface{}, string, error) {
describeOpts := &kinesis.DescribeStreamInput{ describeOpts := &kinesis.DescribeStreamInput{
StreamName: aws.String(sn), StreamName: aws.String(sn),
Limit: aws.Int64(1),
} }
resp, err := conn.DescribeStream(describeOpts) resp, err := conn.DescribeStream(describeOpts)
if err != nil { if err != nil {

View File

@ -3,6 +3,7 @@ package aws
import ( import (
"fmt" "fmt"
"math/rand" "math/rand"
"strconv"
"strings" "strings"
"testing" "testing"
"time" "time"
@ -46,7 +47,6 @@ func testAccCheckKinesisStreamExists(n string, stream *kinesis.StreamDescription
conn := testAccProvider.Meta().(*AWSClient).kinesisconn conn := testAccProvider.Meta().(*AWSClient).kinesisconn
describeOpts := &kinesis.DescribeStreamInput{ describeOpts := &kinesis.DescribeStreamInput{
StreamName: aws.String(rs.Primary.Attributes["name"]), StreamName: aws.String(rs.Primary.Attributes["name"]),
Limit: aws.Int64(1),
} }
resp, err := conn.DescribeStream(describeOpts) resp, err := conn.DescribeStream(describeOpts)
if err != nil { if err != nil {
@ -71,6 +71,10 @@ func testAccCheckAWSKinesisStreamAttributes(stream *kinesis.StreamDescription) r
if *stream.StreamARN != rs.Primary.Attributes["arn"] { if *stream.StreamARN != rs.Primary.Attributes["arn"] {
return fmt.Errorf("Bad Stream ARN\n\t expected: %s\n\tgot: %s\n", rs.Primary.Attributes["arn"], *stream.StreamARN) return fmt.Errorf("Bad Stream ARN\n\t expected: %s\n\tgot: %s\n", rs.Primary.Attributes["arn"], *stream.StreamARN)
} }
shard_count := strconv.Itoa(len(stream.Shards))
if shard_count != rs.Primary.Attributes["shard_count"] {
return fmt.Errorf("Bad Stream Shard Count\n\t expected: %s\n\tgot: %s\n", rs.Primary.Attributes["shard_count"], shard_count)
}
} }
return nil return nil
} }
@ -84,7 +88,6 @@ func testAccCheckKinesisStreamDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).kinesisconn conn := testAccProvider.Meta().(*AWSClient).kinesisconn
describeOpts := &kinesis.DescribeStreamInput{ describeOpts := &kinesis.DescribeStreamInput{
StreamName: aws.String(rs.Primary.Attributes["name"]), StreamName: aws.String(rs.Primary.Attributes["name"]),
Limit: aws.Int64(1),
} }
resp, err := conn.DescribeStream(describeOpts) resp, err := conn.DescribeStream(describeOpts)
if err == nil { if err == nil {
@ -103,6 +106,6 @@ func testAccCheckKinesisStreamDestroy(s *terraform.State) error {
var testAccKinesisStreamConfig = fmt.Sprintf(` var testAccKinesisStreamConfig = fmt.Sprintf(`
resource "aws_kinesis_stream" "test_stream" { resource "aws_kinesis_stream" "test_stream" {
name = "terraform-kinesis-test-%d" name = "terraform-kinesis-test-%d"
shard_count = 1 shard_count = 2
} }
`, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) `, rand.New(rand.NewSource(time.Now().UnixNano())).Int())