Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_launch_configuration: Prevent ResourceInUse errors caused by eventual consistency during deletion #7819

Merged
merged 1 commit into from
Mar 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions aws/resource_aws_launch_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,19 +563,36 @@ func resourceAwsLaunchConfigurationRead(d *schema.ResourceData, meta interface{}

func resourceAwsLaunchConfigurationDelete(d *schema.ResourceData, meta interface{}) error {
autoscalingconn := meta.(*AWSClient).autoscalingconn
input := &autoscaling.DeleteLaunchConfigurationInput{
LaunchConfigurationName: aws.String(d.Id()),
}

log.Printf("[DEBUG] Deleting Autoscaling Launch Configuration: %s", d.Id())
// Retry for Autoscaling eventual consistency
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := autoscalingconn.DeleteLaunchConfiguration(input)

if isAWSErr(err, autoscaling.ErrCodeResourceInUseFault, "") {
return resource.RetryableError(err)
}

log.Printf("[DEBUG] Launch Configuration destroy: %v", d.Id())
_, err := autoscalingconn.DeleteLaunchConfiguration(
&autoscaling.DeleteLaunchConfigurationInput{
LaunchConfigurationName: aws.String(d.Id()),
})
if err != nil {
if isAWSErr(err, "InvalidConfiguration.NotFound", "") {
log.Printf("[DEBUG] Launch configuration (%s) not found", d.Id())
return nil
}

return err
if err != nil {
return resource.NonRetryableError(err)
}

return nil
})

if isResourceTimeoutError(err) {
_, err = autoscalingconn.DeleteLaunchConfiguration(input)
}

if err != nil {
return fmt.Errorf("error deleting Autoscaling Launch Configuration (%s): %s", d.Id(), err)
}

return nil
Expand Down