Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_default_vpc(region: str) -> 'boto3.resources.factory.ec2.Vpc':
"""
Get the user's default VPC in the provided region.
"""
ec2 = boto3.resource(service_name='ec2', region_name=region)
default_vpc = list(
ec2.vpcs.filter(
Filters=[{'Name': 'isDefault', 'Values': ['true']}]))
if default_vpc:
return default_vpc[0]
else:
raise NoDefaultVPC(region=region)