diff --git a/builtin/providers/aws/resource_aws_lambda_permission.go b/builtin/providers/aws/resource_aws_lambda_permission.go index 6019d79debc6..ac8c59c49992 100644 --- a/builtin/providers/aws/resource_aws_lambda_permission.go +++ b/builtin/providers/aws/resource_aws_lambda_permission.go @@ -99,7 +99,8 @@ func resourceAwsLambdaPermissionCreate(d *schema.ResourceData, meta interface{}) if awsErr, ok := err.(awserr.Error); ok { // IAM is eventually consistent :/ if awsErr.Code() == "ResourceConflictException" { - return fmt.Errorf("[WARN] Error creating ELB Listener with SSL Cert, retrying: %s", err) + return fmt.Errorf("[WARN] Error adding new Lambda Permission for %s, retrying: %s", + *input.FunctionName, err) } } return resource.RetryError{Err: err} @@ -115,7 +116,20 @@ func resourceAwsLambdaPermissionCreate(d *schema.ResourceData, meta interface{}) d.SetId(d.Get("statement_id").(string)) - return resourceAwsLambdaPermissionRead(d, meta) + err = resource.Retry(3*time.Minute, func() error { + // IAM is eventually cosistent :/ + err := resourceAwsLambdaPermissionRead(d, meta) + if err != nil { + if strings.HasPrefix(err.Error(), "Error reading Lambda policy: ResourceNotFoundException") { + return fmt.Errorf("[WARN] Error reading newly created Lambda Permission for %s, retrying: %s", + *input.FunctionName, err) + } + return resource.RetryError{Err: err} + } + return nil + }) + + return err } func resourceAwsLambdaPermissionRead(d *schema.ResourceData, meta interface{}) error {