Skip to content

Commit

Permalink
Implement fixes per review (to be squashed later)
Browse files Browse the repository at this point in the history
  • Loading branch information
Radek Simko committed Feb 12, 2016
1 parent 1d6d9ee commit 3b6373a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions builtin/providers/aws/resource_aws_lambda_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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 {
Expand Down

0 comments on commit 3b6373a

Please sign in to comment.