in subfunctions/ALE_dryrun_single.py [0:0]
def dryrun_route_53_query_logs(region_list, account_number):
"""Function to turn on Route 53 Query Logs for VPCs"""
for aws_region in region_list:
logging.info("Turning on Route 53 Query Logging on for VPCs in region " + aws_region + ".")
ec2 = boto3.client('ec2', region_name=aws_region)
route53resolver = boto3.client('route53resolver', region_name=aws_region)
try:
VPCList: list = []
QueryLogList: list = []
logging.info("DescribeVpcs API Call")
vpcs = ec2.describe_vpcs()
for vpc_id in vpcs["Vpcs"]:
VPCList.append(vpc_id["VpcId"])
logging.info("List of VPCs found within account " + account_number + ", region " + aws_region + ":")
print(VPCList)
logging.info("ListResolverQueryLogConfigAssociations API Call")
query_log_details = route53resolver.list_resolver_query_log_config_associations()
for query_log_vpc_id in query_log_details['ResolverQueryLogConfigAssociations']:
QueryLogList.append(query_log_vpc_id['ResourceId'])
r53_working_list = (list(set(VPCList) - set(QueryLogList)))
logging.info("List of VPCs found within account " + account_number + ", region " + aws_region + " WITHOUT Route 53 Query Logs:")
print(r53_working_list)
for no_query_logs in r53_working_list:
logging.info(no_query_logs + " does not have Route 53 Query logging on. Running Assisted Log Enabler for AWS will turn this on.")
except Exception as exception_handle:
logging.error(exception_handle)