From 2a12f14ac7d6ee608c6dfbce1bb0650f63529aa9 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Tue, 23 Jan 2018 12:04:41 +0000 Subject: [PATCH] resource/aws_kinesis_stream: Retry deletion on LimitExceededException --- aws/resource_aws_kinesis_stream.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/aws/resource_aws_kinesis_stream.go b/aws/resource_aws_kinesis_stream.go index 49ffaa4dcf5..87b050e3d6c 100644 --- a/aws/resource_aws_kinesis_stream.go +++ b/aws/resource_aws_kinesis_stream.go @@ -108,12 +108,12 @@ func resourceAwsKinesisStreamCreate(d *schema.ResourceData, meta interface{}) er err := resource.Retry(5*time.Minute, func() *resource.RetryError { _, err := conn.CreateStream(createOpts) - if isAWSErr(err, "LimitExceededException", "simultaneously be in CREATING or DELETING") { + if isAWSErr(err, kinesis.ErrCodeLimitExceededException, "simultaneously be in CREATING or DELETING") { return resource.RetryableError(err) } // AWS (un)helpfully raises LimitExceededException // rather than ThrottlingException here - if isAWSErr(err, "LimitExceededException", "Rate exceeded for stream") { + if isAWSErr(err, kinesis.ErrCodeLimitExceededException, "Rate exceeded for stream") { return resource.RetryableError(err) } return resource.NonRetryableError(err) @@ -221,10 +221,20 @@ 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(sn), - }) + err := resource.Retry(5*time.Minute, func() *resource.RetryError { + _, err := conn.DeleteStream(&kinesis.DeleteStreamInput{ + StreamName: aws.String(sn), + }) + if err != nil { + if isAWSErr(err, kinesis.ErrCodeLimitExceededException, "Rate exceeded for stream") { + return resource.RetryableError(err) + } + + return resource.NonRetryableError(err) + } + return nil + }) if err != nil { return err }