From 7796dfbea58bb16063175f225d3cf821bc56efa2 Mon Sep 17 00:00:00 2001 From: Ryn Daniels Date: Mon, 22 Jul 2019 18:35:35 +0200 Subject: [PATCH] Final retries for config timeouts --- aws/resource_aws_config_config_rule.go | 15 +++++++++++---- aws/resource_aws_config_delivery_channel.go | 9 +++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/aws/resource_aws_config_config_rule.go b/aws/resource_aws_config_config_rule.go index 50d4df7d32a..38c1a721e7d 100644 --- a/aws/resource_aws_config_config_rule.go +++ b/aws/resource_aws_config_config_rule.go @@ -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) @@ -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) @@ -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) } diff --git a/aws/resource_aws_config_delivery_channel.go b/aws/resource_aws_config_delivery_channel.go index 95bff5548da..637c46f7fc2 100644 --- a/aws/resource_aws_config_delivery_channel.go +++ b/aws/resource_aws_config_delivery_channel.go @@ -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) } @@ -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) }