DEV Community

akloya
akloya

Posted on

List AWS Lambda functions not associated with VPC

AWS Lambdas has gained lot of popularity and most of the companies use them today.

For some of security requirements we might have a need where in you want to pull all lambdas that are not associated to VPC. script below can help you do that.

import boto3
from botocore.exceptions import ClientError

client = boto3.client('lambda')
response = client.list_functions()
for function in response['Functions']:
    try:
        response = client.get_function(
            FunctionName=function['FunctionName']
        )
        vpcid = response['Configuration']['VpcConfig']['VpcId']
    except KeyError:
        print("==>" + function['FunctionName'])
    except ClientError as e:
        print("[ERROR] Invoking Lambda Function" + e)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)