From ebf6e51b32ed016d6505655f301609684a50b135 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Fri, 5 Aug 2016 07:12:27 +0100 Subject: [PATCH] provider/aws: Retry association of IAM Role & instance profile (#7938) --- builtin/providers/aws/resource_aws_instance.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index ebd611109..4204debb3 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -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