Skip to content

Commit

Permalink
Merge pull request #2452 from zollie/f-aws-launch-configuration-profi…
Browse files Browse the repository at this point in the history
…le-propagation-wait

provider/aws: Add retry to aws_launch_configuration Create to wait for IAM instance profile propagation
  • Loading branch information
mitchellh committed Jun 25, 2015
2 parents 38efe4c + 579b33b commit a4070a1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion builtin/providers/aws/resource_aws_launch_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,24 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface

log.Printf(
"[DEBUG] autoscaling create launch configuration: %#v", createLaunchConfigurationOpts)
_, err := autoscalingconn.CreateLaunchConfiguration(&createLaunchConfigurationOpts)

// IAM profiles can take ~10 seconds to propagate in AWS:
// http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#launch-instance-with-role-console
err := resource.Retry(30*time.Second, func() error {
_, err := autoscalingconn.CreateLaunchConfiguration(&createLaunchConfigurationOpts)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Message() == "Invalid IamInstanceProfile" {
return err
}
}
return &resource.RetryError{
Err: err,
}
}
return nil
})

if err != nil {
return fmt.Errorf("Error creating launch configuration: %s", err)
}
Expand Down

0 comments on commit a4070a1

Please sign in to comment.