def query_vpc(region):
    'Method to query VPC against given region and respective subnets.\n    Args:\n        region (str): Region name to query the VPC.\n    Returns:\n        vpc and subnet info (obj): Object with region and zone subnet id.\n    '
    per_vpc_info = {}
    raw_client = boto3.client('ec2', region_name=region)
    zones = [z['ZoneName'] for z in raw_client.describe_availability_zones(Filters=get_filters('state', 'available')).get('AvailabilityZones', [])]
    subnets_by_zone = {z: [] for z in zones}
    client = get_client(region)
    per_vpc_sgs = {}
    sgs = client.security_groups.all()
    for sg in sgs:
        sg_list = per_vpc_sgs.setdefault(sg.vpc_id, [])
        sg_list.append({'sg_id': sg.group_id, 'sg_name': sg.group_name})
    region_vpcs = client.vpcs.all()
    for vpc in region_vpcs:
        subnets = vpc.subnets.filter(Filters=get_filters('state', 'available'))
        for s in subnets:
            subnets_for_this_az = subnets_by_zone.setdefault(s.availability_zone, [])
            subnets_for_this_az.append({'subnet_id': s.subnet_id, 'name': _get_name_from_tags(s.tags), 'public': s.map_public_ip_on_launch})
        vpc_info = {'subnets_by_zone': subnets_by_zone, 'security_groups': per_vpc_sgs.get(vpc.id, [])}
        per_vpc_info[vpc.id] = vpc_info
    region_json = {'per_vpc_info': per_vpc_info}
    return region_json
Method to query VPC against given region and respective subnets.
Args:
    region (str): Region name to query the VPC.
Returns:
    vpc and subnet info (obj): Object with region and zone subnet id.
def query_vpc(region):
    'Method to query VPC against given region and respective subnets.\n    Args:\n        region (str): Region name to query the VPC.\n    Returns:\n        vpc and subnet info (obj): Object with region and zone subnet id.\n    '
    per_vpc_info = {}
    raw_client = boto3.client('ec2', region_name=region)
    zones = [z['ZoneName'] for z in raw_client.describe_availability_zones(Filters=get_filters('state', 'available')).get('AvailabilityZones', [])]
    subnets_by_zone = {z: [] for z in zones}
    client = get_client(region)
    per_vpc_sgs = {}
    sgs = client.security_groups.all()
    for sg in sgs:
        sg_list = per_vpc_sgs.setdefault(sg.vpc_id, [])
        sg_list.append({'sg_id': sg.group_id, 'sg_name': sg.group_name})
    region_vpcs = client.vpcs.all()
    for vpc in region_vpcs:
        subnets = vpc.subnets.filter(Filters=get_filters('state', 'available'))
        for s in subnets:
            subnets_for_this_az = subnets_by_zone.setdefault(s.availability_zone, [])
            subnets_for_this_az.append({'subnet_id': s.subnet_id, 'name': _get_name_from_tags(s.tags), 'public': s.map_public_ip_on_launch})
        vpc_info = {'subnets_by_zone': subnets_by_zone, 'security_groups': per_vpc_sgs.get(vpc.id, [])}
        per_vpc_info[vpc.id] = vpc_info
    region_json = {'per_vpc_info': per_vpc_info}
    return region_json