Retry InvalidParameterValueException errors due to newly created resources
This commit is contained in:
parent
86882e39ed
commit
bfa4a88170
|
@ -3,10 +3,13 @@ package aws
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/lambda"
|
"github.com/aws/aws-sdk-go/service/lambda"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -88,14 +91,28 @@ func resourceAwsLambdaEventSourceMappingCreate(d *schema.ResourceData, meta inte
|
||||||
Enabled: aws.Bool(d.Get("enabled").(bool)),
|
Enabled: aws.Bool(d.Get("enabled").(bool)),
|
||||||
}
|
}
|
||||||
|
|
||||||
eventSourceMappingConfiguration, err := conn.CreateEventSourceMapping(params)
|
err := resource.Retry(1*time.Minute, func() error {
|
||||||
|
eventSourceMappingConfiguration, err := conn.CreateEventSourceMapping(params)
|
||||||
|
if err != nil {
|
||||||
|
if awserr, ok := err.(awserr.Error); ok {
|
||||||
|
if awserr.Code() == "InvalidParameterValueException" {
|
||||||
|
// Retryable
|
||||||
|
return awserr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Not retryable
|
||||||
|
return resource.RetryError{Err: err}
|
||||||
|
}
|
||||||
|
// No error
|
||||||
|
d.Set("uuid", eventSourceMappingConfiguration.UUID)
|
||||||
|
d.SetId(*eventSourceMappingConfiguration.UUID)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating Lambda event source mapping: %s", err)
|
return fmt.Errorf("Error creating Lambda event source mapping: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("uuid", eventSourceMappingConfiguration.UUID)
|
|
||||||
d.SetId(*eventSourceMappingConfiguration.UUID)
|
|
||||||
|
|
||||||
return resourceAwsLambdaEventSourceMappingRead(d, meta)
|
return resourceAwsLambdaEventSourceMappingRead(d, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue