Skip to content

Commit

Permalink
Merge pull request #9438 from terraform-providers/rfd-retry-config
Browse files Browse the repository at this point in the history
Final retries for config timeouts
  • Loading branch information
ryndaniels authored Jul 24, 2019
2 parents baf2034 + 7796dfb commit 81e453b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
15 changes: 11 additions & 4 deletions aws/resource_aws_config_config_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ func resourceAwsConfigConfigRulePut(d *schema.ResourceData, meta interface{}) er

return nil
})
if isResourceTimeoutError(err) {
_, err = conn.PutConfigRule(&input)
}
if err != nil {
return err
return fmt.Errorf("Error creating AWSConfig rule: %s", err)
}

d.SetId(name)
Expand Down Expand Up @@ -242,10 +245,11 @@ func resourceAwsConfigConfigRuleDelete(d *schema.ResourceData, meta interface{})
name := d.Get("name").(string)

log.Printf("[DEBUG] Deleting AWS Config config rule %q", name)
input := &configservice.DeleteConfigRuleInput{
ConfigRuleName: aws.String(name),
}
err := resource.Retry(2*time.Minute, func() *resource.RetryError {
_, err := conn.DeleteConfigRule(&configservice.DeleteConfigRuleInput{
ConfigRuleName: aws.String(name),
})
_, err := conn.DeleteConfigRule(input)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "ResourceInUseException" {
return resource.RetryableError(err)
Expand All @@ -254,6 +258,9 @@ func resourceAwsConfigConfigRuleDelete(d *schema.ResourceData, meta interface{})
}
return nil
})
if isResourceTimeoutError(err) {
_, err = conn.DeleteConfigRule(input)
}
if err != nil {
return fmt.Errorf("Deleting Config Rule failed: %s", err)
}
Expand Down
9 changes: 7 additions & 2 deletions aws/resource_aws_config_delivery_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ func resourceAwsConfigDeliveryChannelPut(d *schema.ResourceData, meta interface{
return nil
}

awsErr, ok := err.(awserr.Error)
if ok && awsErr.Code() == "InsufficientDeliveryPolicyException" {
if isAWSErr(err, "InsufficientDeliveryPolicyException", "") {
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
})
if isResourceTimeoutError(err) {
_, err = conn.PutDeliveryChannel(&input)
}
if err != nil {
return fmt.Errorf("Creating Delivery Channel failed: %s", err)
}
Expand Down Expand Up @@ -175,6 +177,9 @@ func resourceAwsConfigDeliveryChannelDelete(d *schema.ResourceData, meta interfa
}
return nil
})
if isResourceTimeoutError(err) {
_, err = conn.DeleteDeliveryChannel(&input)
}
if err != nil {
return fmt.Errorf("Unable to delete delivery channel: %s", err)
}
Expand Down

0 comments on commit 81e453b

Please sign in to comment.