provider/aws: Retry association of IAM Role & instance profile (#7938)

This commit is contained in:
Radek Simko 2016-08-05 07:12:27 +01:00 committed by Paul Stack
parent 3982495723
commit ebf6e51b32
1 changed files with 7 additions and 2 deletions

View File

@ -366,15 +366,20 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Run configuration: %s", runOpts)
var runResp *ec2.Reservation
err = resource.Retry(10*time.Second, func() *resource.RetryError {
err = resource.Retry(15*time.Second, func() *resource.RetryError {
var err error
runResp, err = conn.RunInstances(runOpts)
// IAM profiles can take ~10 seconds to propagate in AWS:
// IAM instance 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
if isAWSErr(err, "InvalidParameterValue", "Invalid IAM Instance Profile") {
log.Printf("[DEBUG] Invalid IAM Instance Profile referenced, retrying...")
return resource.RetryableError(err)
}
// IAM roles can also take time to propagate in AWS:
if isAWSErr(err, "InvalidParameterValue", " has no associated IAM Roles") {
log.Printf("[DEBUG] IAM Instance Profile appears to have no IAM roles, retrying...")
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
})
// Warn if the AWS Error involves group ids, to help identify situation