def lambda_handler()

in source/verify-ta-check-status-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 = verify_trusted_advisor_check_status(supportClient, 
                    event['CheckId']) 
        logger.info("Append the Refresh Status '"+response['statuses'][0]['status']+"' to response." +
            " This will be consumed by downstream Lambda")
        event["RefreshStatus"] = response['statuses'][0]['status']
        logger.info("Refresh for Check "+event['CheckId']+" Returned Refresh Wait Time in Seconds:"+ str((response['statuses'][0]['millisUntilNextRefreshable'])/1000))
        logger.info("Rounding Wait Time to:"+str(round((response['statuses'][0]['millisUntilNextRefreshable'])/1000)))
        if round((response['statuses'][0]['millisUntilNextRefreshable'])/1000) <= 3600:
            event['WaitTimeInSec']= round((response['statuses'][0]['millisUntilNextRefreshable'])/1000)
        else:
            logger.info("Skipping Refresh for Check "+event['CheckId']+" as wait time"+ str(round((response['statuses'][0]['millisUntilNextRefreshable'])/1000))+ "is greater than 1 hour")
            event['WaitTimeInSec']= 0
        return event
    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)