AWS Lambda is a powerful tool that can automate many tasks in the cloud, but what happens when Lambda functions go unused? They can become a burden if not managed well, consuming valuable resources and possibly incurring unnecessary costs. This blog post walks you through the steps to enumerate AWS Lambda functions across all regions and detect dead or unused functions using the List Lambdas project.
Motivation
With the challenge of identifying dead Lambda functions, we encourage you to read our blog post, “The Curse of Dead Lambda Functions,” available at https://epsagon.com/tools/the-curse-of-dead-aws-lambda-functions.
Setup
Getting started is as easy as following these steps:
- Clone the repository:
git clone https://github.com/epsagon/list-lambdas
cd list-lambdas
pip install -r requirements.txt
python list_lambdas.py
Using Docker
If you prefer using Docker for your environment, simply follow these steps:
- Clone the repository:
git clone https://github.com/epsagon/list-lambdas
cd list-lambdas
docker build -t list_lambdas:latest .
docker run --rm -v $HOME/.aws:/root/.aws -t list_lambdas:latest --profile myprofile
Example Outputs
When you execute the commands, the outputs are displayed in various formats:
- Command Line Interface (CLI):
- CSV file:
Usage
Here are some useful command options to refine your search:
- Filter Lambda functions inactive in the last 10 days:
python list_lambdas.py --inactive-days-filter 10
python list_lambdas.py --all
python list_lambdas.py --sort-by last-invocation
python list_lambdas.py --csv lambdas.csv
python list_lambdas.py --token-key-id access_key_id --token-secret secret_access_key
Troubleshooting
If you encounter any issues while setting this up, consider the following troubleshooting tips:
- Ensure you have the correct AWS permissions for listing Lambda functions.
- Make sure the AWS CLI is configured properly with the right profile.
- Check that all dependencies are installed. If there are errors in installations, retry the
pip installcommand. - For Docker users, verify that Docker is running and configured properly.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.
Code Analogy
Think of listing Lambda functions like checking the inventory of a store. Each Lambda function represents a product on the shelf. Over time, some products may become outdated or are simply not bought anymore, leading to an accumulation of unused inventory. Our list-lambdas script helps ‘stock managers’ (developers) identify which products (Lambda functions) should be removed or updated, ensuring that only the most relevant and active items are showcased to the customers (users), optimizing the store’s (cloud service’s) efficiency and cost.

