provider/aws: fix instance profile creation false negative

fixes https://github.com/hashicorp/terraform/issues/9474

discussion of approach in https://github.com/hashicorp/terraform/pull/11634
This commit is contained in:
Paul Tittle 2017-02-03 13:27:50 -05:00
parent ae002bf41b
commit bd5fc5d0e0
1 changed files with 11 additions and 0 deletions

View File

@ -121,6 +121,17 @@ func resourceAwsIamInstanceProfileCreate(d *schema.ResourceData, meta interface{
return fmt.Errorf("Error creating IAM instance profile %s: %s", name, err)
}
waiterRequest := &iam.GetInstanceProfileInput{
InstanceProfileName: aws.String(name),
}
// don't return until the IAM service reports that the instance profile is ready.
// this ensures that terraform resources which rely on the instance profile will 'see'
// that the instance profile exists.
err = iamconn.WaitUntilInstanceProfileExists(waiterRequest)
if err != nil {
return fmt.Errorf("Timed out while waiting for instance profile %s: %s", name, err)
}
return instanceProfileSetRoles(d, iamconn)
}