Skip to content

Commit

Permalink
Merge pull request #9013 from terraform-providers/rfd-retry-elasticache
Browse files Browse the repository at this point in the history
Final retries for elasticache
  • Loading branch information
ryndaniels authored Jun 19, 2019
2 parents d92923f + 7f07aaa commit 9826e21
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
20 changes: 16 additions & 4 deletions aws/resource_aws_elasticache_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ func resourceAwsElasticacheParameterGroupUpdate(d *schema.ResourceData, meta int
func resourceAwsElasticacheParameterGroupDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticacheconn

return resource.Retry(3*time.Minute, func() *resource.RetryError {
deleteOpts := elasticache.DeleteCacheParameterGroupInput{
CacheParameterGroupName: aws.String(d.Id()),
}
deleteOpts := elasticache.DeleteCacheParameterGroupInput{
CacheParameterGroupName: aws.String(d.Id()),
}
err := resource.Retry(3*time.Minute, func() *resource.RetryError {
_, err := conn.DeleteCacheParameterGroup(&deleteOpts)
if err != nil {
awsErr, ok := err.(awserr.Error)
Expand All @@ -335,6 +335,18 @@ func resourceAwsElasticacheParameterGroupDelete(d *schema.ResourceData, meta int
}
return nil
})
if isResourceTimeoutError(err) {
_, err = conn.DeleteCacheParameterGroup(&deleteOpts)
}
if isAWSErr(err, elasticache.ErrCodeCacheParameterGroupNotFoundFault, "") {
return nil
}

if err != nil {
return fmt.Errorf("error deleting Elasticache Parameter Group (%s): %s", d.Id(), err)
}

return nil
}

func resourceAwsElasticacheParameterHash(v interface{}) int {
Expand Down
10 changes: 9 additions & 1 deletion aws/resource_aws_elasticache_replication_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,16 @@ func deleteElasticacheReplicationGroup(replicationGroupID string, conn *elastica
}
return nil
})
if isResourceTimeoutError(err) {
_, err = conn.DeleteReplicationGroup(input)
}

if isAWSErr(err, elasticache.ErrCodeReplicationGroupNotFoundFault, "") {
return nil
}

if err != nil {
return err
return fmt.Errorf("error deleting Elasticache Replication Group: %s", err)
}

log.Printf("[DEBUG] Waiting for deletion: %s", replicationGroupID)
Expand Down
17 changes: 16 additions & 1 deletion aws/resource_aws_elasticache_subnet_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func resourceAwsElasticacheSubnetGroupDelete(d *schema.ResourceData, meta interf

log.Printf("[DEBUG] Cache subnet group delete: %s", d.Id())

return resource.Retry(5*time.Minute, func() *resource.RetryError {
err := resource.Retry(5*time.Minute, func() *resource.RetryError {
_, err := conn.DeleteCacheSubnetGroup(&elasticache.DeleteCacheSubnetGroupInput{
CacheSubnetGroupName: aws.String(d.Id()),
})
Expand All @@ -173,4 +173,19 @@ func resourceAwsElasticacheSubnetGroupDelete(d *schema.ResourceData, meta interf
}
return nil
})
if isResourceTimeoutError(err) {
_, err = conn.DeleteCacheSubnetGroup(&elasticache.DeleteCacheSubnetGroupInput{
CacheSubnetGroupName: aws.String(d.Id()),
})
}

if isAWSErr(err, elasticache.ErrCodeCacheSubnetGroupNotFoundFault, "") {
return nil
}

if err != nil {
return fmt.Errorf("error deleting Elasticache Subnet Group (%s): %s", d.Id(), err)
}

return nil
}

0 comments on commit 9826e21

Please sign in to comment.