diff --git a/aws/data_source_aws_kinesis_stream_test.go b/aws/data_source_aws_kinesis_stream_test.go index 815724ae893..49108d846ec 100644 --- a/aws/data_source_aws_kinesis_stream_test.go +++ b/aws/data_source_aws_kinesis_stream_test.go @@ -3,6 +3,7 @@ package aws import ( "fmt" "testing" + "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/kinesis" @@ -26,7 +27,7 @@ func TestAccAWSKinesisStreamDataSource(t *testing.T) { if err != nil { t.Fatalf("Error calling UpdateShardCount: %s", err) } - if err := waitForKinesisToBeActive(conn, sn); err != nil { + if err := waitForKinesisToBeActive(conn, 5*time.Minute, sn); err != nil { t.Fatal(err) } } diff --git a/aws/resource_aws_kinesis_stream.go b/aws/resource_aws_kinesis_stream.go index 6f71ed308a0..a1adcd96e48 100644 --- a/aws/resource_aws_kinesis_stream.go +++ b/aws/resource_aws_kinesis_stream.go @@ -22,6 +22,12 @@ func resourceAwsKinesisStream() *schema.Resource { State: resourceAwsKinesisStreamImport, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(120 * time.Minute), + Delete: schema.DefaultTimeout(120 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, @@ -91,7 +97,7 @@ func resourceAwsKinesisStreamCreate(d *schema.ResourceData, meta interface{}) er Pending: []string{"CREATING"}, Target: []string{"ACTIVE"}, Refresh: streamStateRefreshFunc(conn, sn), - Timeout: 5 * time.Minute, + Timeout: d.Timeout(schema.TimeoutCreate), Delay: 10 * time.Second, MinTimeout: 3 * time.Second, } @@ -189,7 +195,7 @@ func resourceAwsKinesisStreamDelete(d *schema.ResourceData, meta interface{}) er Pending: []string{"DELETING"}, Target: []string{"DESTROYED"}, Refresh: streamStateRefreshFunc(conn, sn), - Timeout: 5 * time.Minute, + Timeout: d.Timeout(schema.TimeoutDelete), Delay: 10 * time.Second, MinTimeout: 3 * time.Second, } @@ -238,7 +244,7 @@ func setKinesisRetentionPeriod(conn *kinesis.Kinesis, d *schema.ResourceData) er } } - if err := waitForKinesisToBeActive(conn, sn); err != nil { + if err := waitForKinesisToBeActive(conn, d.Timeout(schema.TimeoutUpdate), sn); err != nil { return err } @@ -267,7 +273,7 @@ func updateKinesisShardCount(conn *kinesis.Kinesis, d *schema.ResourceData) erro return err } - if err := waitForKinesisToBeActive(conn, sn); err != nil { + if err := waitForKinesisToBeActive(conn, d.Timeout(schema.TimeoutUpdate), sn); err != nil { return err } @@ -302,7 +308,7 @@ func updateKinesisShardLevelMetrics(conn *kinesis.Kinesis, d *schema.ResourceDat if err != nil { return fmt.Errorf("Failure to disable shard level metrics for stream %s: %s", sn, err) } - if err := waitForKinesisToBeActive(conn, sn); err != nil { + if err := waitForKinesisToBeActive(conn, d.Timeout(schema.TimeoutUpdate), sn); err != nil { return err } } @@ -321,7 +327,7 @@ func updateKinesisShardLevelMetrics(conn *kinesis.Kinesis, d *schema.ResourceDat if err != nil { return fmt.Errorf("Failure to enable shard level metrics for stream %s: %s", sn, err) } - if err := waitForKinesisToBeActive(conn, sn); err != nil { + if err := waitForKinesisToBeActive(conn, d.Timeout(schema.TimeoutUpdate), sn); err != nil { return err } } @@ -375,12 +381,12 @@ func streamStateRefreshFunc(conn *kinesis.Kinesis, sn string) resource.StateRefr } } -func waitForKinesisToBeActive(conn *kinesis.Kinesis, sn string) error { +func waitForKinesisToBeActive(conn *kinesis.Kinesis, timeout time.Duration, sn string) error { stateConf := &resource.StateChangeConf{ Pending: []string{"UPDATING"}, Target: []string{"ACTIVE"}, Refresh: streamStateRefreshFunc(conn, sn), - Timeout: 5 * time.Minute, + Timeout: timeout, Delay: 10 * time.Second, MinTimeout: 3 * time.Second, }