in source/refresh-ta-check-lambda.py [0:0]
def lambda_handler(event, context):
try:
logger.info(sanitize_json(event))
logger.info("Assume Role in child account")
roleCredentials=assumeRole(event['AccountId'])
logger.info("Create boto3 support client using the temporary credentials")
supportClient=boto3.client("support",region_name="us-east-1",
aws_access_key_id = roleCredentials['Credentials']['AccessKeyId'],
aws_secret_access_key =
roleCredentials['Credentials']['SecretAccessKey'],
aws_session_token=roleCredentials['Credentials']['SessionToken'])
response = refresh_trusted_advisor_checks(
supportClient, event['CheckId'])
logger.info("Append the Refresh Status '"+response['status']['status']+"' to response." +
" This will be consumed by downstream Lambda")
event["RefreshStatus"] = response['status']['status']
return event
except ClientError as e:
checkAssumeRoleFailure(str(e))
e=sanitize_string(e)
logger.error("Unexpected client error %s" % e)
raise AWSTrustedAdvisorExplorerGenericException(e)
except Exception as f:
checkAssumeRoleFailure(str(f))
f=sanitize_string(f)
logger.error("Unexpected exception: %s" % f)
raise AWSTrustedAdvisorExplorerGenericException(f)