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

Final retry after timeout deleting inspector assessment target #9767

Merged
merged 1 commit into from
Aug 16, 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
18 changes: 12 additions & 6 deletions aws/resource_aws_inspector_assessment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ func resourceAwsInspectorAssessmentTargetUpdate(d *schema.ResourceData, meta int

func resourceAwsInspectorAssessmentTargetDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).inspectorconn

return resource.Retry(60*time.Minute, func() *resource.RetryError {
_, err := conn.DeleteAssessmentTarget(&inspector.DeleteAssessmentTargetInput{
AssessmentTargetArn: aws.String(d.Id()),
})
input := &inspector.DeleteAssessmentTargetInput{
AssessmentTargetArn: aws.String(d.Id()),
}
err := resource.Retry(60*time.Minute, func() *resource.RetryError {
_, err := conn.DeleteAssessmentTarget(input)

if isAWSErr(err, inspector.ErrCodeAssessmentRunInProgressException, "") {
return resource.RetryableError(err)
Expand All @@ -120,7 +120,13 @@ func resourceAwsInspectorAssessmentTargetDelete(d *schema.ResourceData, meta int

return nil
})

if isResourceTimeoutError(err) {
_, err = conn.DeleteAssessmentTarget(input)
}
if err != nil {
return fmt.Errorf("Error deleting Inspector Assessment Target: %s", err)
}
return nil
}

func describeInspectorAssessmentTarget(conn *inspector.Inspector, arn string) (*inspector.AssessmentTarget, error) {
Expand Down