diff -r dd6a9723ae2b -r 8dc22a209420 contrib/automation/hgautomation/aws.py --- a/contrib/automation/hgautomation/aws.py Fri Apr 19 05:20:33 2019 -0700 +++ b/contrib/automation/hgautomation/aws.py Sat Apr 27 11:38:58 2019 -0700 @@ -196,7 +196,7 @@ if ensure_ec2_state: ensure_key_pairs(automation.state_path, self.ec2resource) self.security_groups = ensure_security_groups(self.ec2resource) - ensure_iam_state(self.iamresource) + ensure_iam_state(self.iamclient, self.iamresource) def key_pair_path_private(self, name): """Path to a key pair private key file.""" @@ -325,7 +325,7 @@ profile.delete() -def ensure_iam_state(iamresource, prefix='hg-'): +def ensure_iam_state(iamclient, iamresource, prefix='hg-'): """Ensure IAM state is in sync with our canonical definition.""" remote_profiles = {} @@ -361,6 +361,10 @@ InstanceProfileName=actual) remote_profiles[name] = profile + waiter = iamclient.get_waiter('instance_profile_exists') + waiter.wait(InstanceProfileName=actual) + print('IAM instance profile %s is available' % actual) + for name in sorted(set(IAM_ROLES) - set(remote_roles)): entry = IAM_ROLES[name] @@ -373,6 +377,10 @@ AssumeRolePolicyDocument=ASSUME_ROLE_POLICY_DOCUMENT, ) + waiter = iamclient.get_waiter('role_exists') + waiter.wait(RoleName=actual) + print('IAM role %s is available' % actual) + remote_roles[name] = role for arn in entry['policy_arns']: