@@ -499,40 +499,52 @@ func resourceClusterDelete(d *schema.ResourceData, meta interface{}) error {
499
499
500
500
log .Printf ("[DEBUG] Deleting EKS Cluster: %s" , d .Id ())
501
501
502
+ input := & eks.DeleteClusterInput {
503
+ Name : aws .String (d .Id ()),
504
+ }
505
+
502
506
// If a cluster is scaling up due to load a delete request will fail
503
507
// This is a temporary workaround until EKS supports multiple parallel mutating operations
504
- return tfresource .RetryConfigContext (context .TODO (), 0 * time .Second , 1 * time .Minute , 0 * time .Second , 30 * time .Second , clusterDeleteRetryTimeout , func () * resource.RetryError {
505
- _ , err := conn .DeleteCluster (& eks.DeleteClusterInput {
506
- Name : aws .String (d .Id ()),
507
- })
508
-
509
- if tfawserr .ErrCodeEquals (err , eks .ErrCodeResourceNotFoundException ) {
510
- return nil
511
- }
508
+ err := tfresource .RetryConfigContext (context .Background (), 0 * time .Second , 1 * time .Minute , 0 * time .Second , 30 * time .Second , clusterDeleteRetryTimeout , func () * resource.RetryError {
509
+ var err error
512
510
513
- // Sometimes the EKS API returns the ResourceNotFound error in this form:
514
- // ClientException: No cluster found for name: tf-acc-test-0o1f8
515
- if tfawserr .ErrMessageContains (err , eks .ErrCodeClientException , "No cluster found for name:" ) {
516
- return nil
517
- }
511
+ _ , err = conn .DeleteCluster (input )
518
512
519
513
if tfawserr .ErrMessageContains (err , eks .ErrCodeResourceInUseException , "in progress" ) {
520
514
log .Printf ("[DEBUG] eks cluster update in progress: %v" , err )
521
515
return resource .RetryableError (err )
522
516
}
523
517
524
518
if err != nil {
525
- return resource .NonRetryableError (fmt . Errorf ( "error deleting EKS Cluster (%s): %w" , d . Id (), err ) )
519
+ return resource .NonRetryableError (err )
526
520
}
527
521
528
- _ , err = waitClusterDeleted (conn , d .Id (), d .Timeout (schema .TimeoutDelete ))
522
+ return nil
523
+ })
529
524
530
- if err != nil {
531
- return resource . NonRetryableError ( fmt . Errorf ( "error waiting for EKS Cluster (%s) to delete: %w" , d . Id (), err ) )
532
- }
525
+ if tfresource . TimedOut ( err ) {
526
+ _ , err = conn . DeleteCluster ( input )
527
+ }
533
528
529
+ if tfawserr .ErrCodeEquals (err , eks .ErrCodeResourceNotFoundException ) {
534
530
return nil
535
- })
531
+ }
532
+
533
+ // Sometimes the EKS API returns the ResourceNotFound error in this form:
534
+ // ClientException: No cluster found for name: tf-acc-test-0o1f8
535
+ if tfawserr .ErrMessageContains (err , eks .ErrCodeClientException , "No cluster found for name:" ) {
536
+ return nil
537
+ }
538
+
539
+ if err != nil {
540
+ return fmt .Errorf ("error deleting EKS Cluster (%s): %w" , d .Id (), err )
541
+ }
542
+
543
+ if _ , err = waitClusterDeleted (conn , d .Id (), d .Timeout (schema .TimeoutDelete )); err != nil {
544
+ return fmt .Errorf ("error waiting for EKS Cluster (%s) to delete: %w" , d .Id (), err )
545
+ }
546
+
547
+ return nil
536
548
}
537
549
538
550
func expandEksEncryptionConfig (tfList []interface {}) []* eks.EncryptionConfig {
0 commit comments