in source/extract-ta-data-lambda.py [0:0]
def lambda_handler(event, context):
if ("Header_"+event['CheckId']) in os.environ and ("Schema_"+event['CheckId']) in os.environ:
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'])
result = genericTAParse(supportClient,event['CheckId'],event['AccountId'],
event['AccountName'],event['AccountEmail'],event['Language'],
event['Date'],event['DateTime'],event['CheckName'],
event['Category'])
logger.info(result)
return result
except ClientError as e:
e = sanitize_string(e)
logger.error("Unexpected client error %s" % e)
raise AWSTrustedAdvisorExplorerGenericException(e)
except Exception as f:
f = sanitize_string(f)
logger.error("Unexpected exception: %s" % f)
raise AWSTrustedAdvisorExplorerGenericException(f)
else:
return "Header_"+event['CheckId']+" not found in env variables; Skipping Check"