Merge pull request #2452 from zollie/f-aws-launch-configuration-profile-propagation-wait

provider/aws: Add retry to aws_launch_configuration Create to wait for IAM instance profile propagation
This commit is contained in:
Mitchell Hashimoto 2015-06-24 22:59:42 -07:00
commit a4070a1972
1 changed files with 18 additions and 1 deletions

View File

@ -373,7 +373,24 @@ func resourceAwsLaunchConfigurationCreate(d *schema.ResourceData, meta interface
log.Printf( log.Printf(
"[DEBUG] autoscaling create launch configuration: %#v", createLaunchConfigurationOpts) "[DEBUG] autoscaling create launch configuration: %#v", 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) _, 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 { if err != nil {
return fmt.Errorf("Error creating launch configuration: %s", err) return fmt.Errorf("Error creating launch configuration: %s", err)
} }