def dryrun_check_cloudtrail()

in subfunctions/ALE_dryrun_single.py [0:0]


def dryrun_check_cloudtrail(account_number):
    """Function to check if CloudTrail is enabled"""
    logging.info("Checking to see if CloudTrail is on, and will activate if needed.")
    try:
        logging.info("DescribeTrails API Call")
        cloudtrail_status = cloudtrail.describe_trails(
            includeShadowTrails=True
        )
        if cloudtrail_status["trailList"][0]["Name"] == "":
            logging.info("There is no CloudTrail trail created within this account. Running Assisted Log Enabler for AWS will create the CloudTrail trail for this account.")
        else:
            cloudtrail_name = cloudtrail_status["trailList"][0]["Name"]
            logging.info("There is a CloudTrail trail active. Name: " + cloudtrail_name)
    except Exception as exception_handle:
        logging.error(exception_handle)