Skip to content

Commit

Permalink
resource/aws_kinesis_stream: Retry deletion on LimitExceededException
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Jan 23, 2018
1 parent 2a36215 commit 2a12f14
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions aws/resource_aws_kinesis_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 2a12f14

Please sign in to comment.