Handle specific exceptions at creation
If we get `InvalidParameterException` with the message "Could not deliver test message to specified" then retry as this is often down to some sort of internal delay in Amazons API. Also increase the timeout from 30 seconds to 3 minutes as it has been observed to take that long sometimes for the creation to succeed. This applies to both log destinations and subscription filters.
This commit is contained in:
parent
e4b4d2b563
commit
93b2ac36dc
|
@ -2,6 +2,7 @@ package aws
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
|
@ -64,7 +65,7 @@ func resourceAwsCloudWatchLogDestinationPut(d *schema.ResourceData, meta interfa
|
|||
TargetArn: aws.String(target_arn),
|
||||
}
|
||||
|
||||
return resource.Retry(30*time.Second, func() *resource.RetryError {
|
||||
return resource.Retry(3*time.Minute, func() *resource.RetryError {
|
||||
resp, err := conn.PutDestination(params)
|
||||
|
||||
if err == nil {
|
||||
|
@ -78,6 +79,9 @@ func resourceAwsCloudWatchLogDestinationPut(d *schema.ResourceData, meta interfa
|
|||
}
|
||||
|
||||
if awsErr.Code() == "InvalidParameterException" {
|
||||
if strings.Contains(awsErr.Message(), "Could not deliver test message to specified") {
|
||||
return resource.RetryableError(err)
|
||||
}
|
||||
return resource.NonRetryableError(err)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
|
@ -56,7 +57,7 @@ func resourceAwsCloudwatchLogSubscriptionFilterCreate(d *schema.ResourceData, me
|
|||
params := getAwsCloudWatchLogsSubscriptionFilterInput(d)
|
||||
log.Printf("[DEBUG] Creating SubscriptionFilter %#v", params)
|
||||
|
||||
return resource.Retry(30*time.Second, func() *resource.RetryError {
|
||||
return resource.Retry(3*time.Minute, func() *resource.RetryError {
|
||||
_, err := conn.PutSubscriptionFilter(¶ms)
|
||||
|
||||
if err == nil {
|
||||
|
@ -71,6 +72,9 @@ func resourceAwsCloudwatchLogSubscriptionFilterCreate(d *schema.ResourceData, me
|
|||
|
||||
if awsErr.Code() == "InvalidParameterException" {
|
||||
log.Printf("[DEBUG] Caught message: %q, code: %q: Retrying", awsErr.Message(), awsErr.Code())
|
||||
if strings.Contains(awsErr.Message(), "Could not deliver test message to specified") {
|
||||
return resource.RetryableError(err)
|
||||
}
|
||||
resource.NonRetryableError(err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue