amazon web services – Listing All Lambda Functions using AWS SDK for Python (boto3)

I am trying to use boto3 to get a list of all the lambdas I have in AWS. I will also need to get metrics from these lambdas (metrics are enabled in AWS console) but presently I just want to list them all. In addition, I just want to get the lambdas based on a filtered tag (ex: get all the lambdas with the tag mygroup:env=dev). This is what I have tried:

 import boto3

 # Create CloudWatch client
 cloudwatch = boto3.client('cloudwatch', region_name="us-west-2")
 lambdas = boto3.client('lambda', region_name="us-west-2")

 lambda_list = lambdas.list_functions(MasterRegion='us-west-2', FunctionVersion='ALL', MaxItems=123)

It returns the following, which essentially is an empty list of the Functions:

 {'ResponseMetadata': {'RequestId': 'eiopo-12mlk-12312-nm',
   'HTTPStatusCode': 200,
   'HTTPHeaders': {'date': 'Fri, 17 Mar 2023 19:43:00 GMT',
    'content-type': 'application/json',
    'content-length': '34',
    'connection': 'keep-alive',
    'x-amzn-requestid': 'e89098asf-123123-746b-a1d34-easd3213456'},
    'RetryAttempts': 0},
    'Functions': []
 }

The Lambdas are there; I can see them in my AWS Lambdas dashboard. What am I doing wrong here and how can I apply a filter for my tags?

Read more here: Source link