in 03-no-iac/access_preview.py [0:0]
def get(self):
number_of_attempts = 0
while True:
response = client.get_access_preview(
accessPreviewId=self.preview_id,
analyzerArn=analyzer_arn
)
status = response['accessPreview']['status']
if status == 'CREATING':
number_of_attempts = number_of_attempts + 1
if number_of_attempts >= 30:
raise Exception(f'Timed out after 1 minute waiting for access analyzer preview to create.')
time.sleep(2)
else:
break
if status == 'FAILED':
reason = response["accessPreview"]["statusReason"]["code"]
raise Exception(f'Failed to create access preview. Reason: {reason}')
# status is created if method makes it to this point
return status