Giter Site home page Giter Site logo

epsagon / list-lambdas Goto Github PK

View Code? Open in Web Editor NEW
186.0 16.0 38.0 259 KB

Enumerate Lambda functions across all regions with useful metadata ๐Ÿ’ก๐Ÿ’ตโš™

Home Page: https://epsagon.com

License: MIT License

Python 98.02% Dockerfile 1.98%
epsagon lambda aws-lambda serverless serverless-functions devops devops-tools

list-lambdas's Introduction

List Lambdas functions =====================

image

(Based on photo by Valve Software / CC BY-SA 4.0)

Motivation

Setup

git clone https://github.com/epsagon/list-lambdas
cd list-lambdas/
pip install -r requirements.txt
python list_lambdas.py

Docker -----.. code-block:: bash

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

CLI:

image

CSV file:

image

Usage

Filter only Lambda functions that have not been active in the last 10 days:

python list_lambdas.py --inactive-days-filter 10

Print extended information to the screen (same as in the CSV file):

python list_lambdas.py --all

Sort by a chosen column (e.g. by last invocation time):

python list_lambdas.py --sort-by last-invocation

Output table (with extra data) to a CSV file:

python list_lambdas.py --csv lambdas.csv

Provide credentials:

python list_lambdas.py --token-key-id <access_key_id> --token-secret <secret_access_key>

list-lambdas's People

Contributors

baocin avatar gliptak avatar jmeg avatar nshap avatar quinnypig avatar ranrib avatar siutsin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

list-lambdas's Issues

--all flag fails to produce output

The standard: "python list_lambdas.py" command completes successfully, but if I add the "--all" flag the following message is produced:

python list_lambdas.py --all
100% (15 of 15) |#############################################################################################################################| Elapsed Time: 0:00:23 Time: 0:00:23
Traceback (most recent call last):
  File "list_lambdas.py", line 251, in <module>
    print_lambda_list(arguments)
  File "list_lambdas.py", line 191, in print_lambda_list
    print(table.table)
  File "C:\Python36\lib\site-packages\terminaltables\base_table.py", line 216, in table
    dimensions = max_dimensions(self.table_data, self.padding_left, self.padding_right)[:3]
  File "C:\Python36\lib\site-packages\terminaltables\width_and_alignment.py", line 106, in max_dimensions
    inner_heights[j] = max(inner_heights[j], cell.count('\n') + 1)
TypeError: a bytes-like object is required, not 'str'

I'm on Windows 10 with Python 3.6.4

UnicodeEncodeError for lambda with non-ASCII description

100% (15 of 15) |####################################| Elapsed Time: 0:00:25 Time: 0:00:25
Traceback (most recent call last):
File "list_lambdas.py", line 230, in
print_lambda_list(args)
File "list_lambdas.py", line 168, in print_lambda_list
min_table_data, all_table_data = create_tables(lambdas_data, args)
File "list_lambdas.py", line 99, in create_tables
str(function_data['Description']),
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 9: ordinal not in range(128)

ValueError: max() arg is an empty sequence

46% (7 of 15) |########################################################################## | Elapsed Time: 0:00:15 ETA: 0:00:18Traceback (most recent call last):
File "list_lambdas.py", line 222, in
print_lambda_list(args)
File "list_lambdas.py", line 143, in print_lambda_list
[log.get('lastEventTimestamp', 0) for log in logs['logStreams']]
ValueError: max() arg is an empty sequence

Sort by

Feature request

is it possible to sort by runtime?

Issue outputting to csv

python3 list_lambdas.py --csv lambdas.csv

Traceback (most recent call last):
  File "list_lambdas.py", line 251, in <module>
    print_lambda_list(arguments)
  File "list_lambdas.py", line 198, in print_lambda_list
    output_file.writelines('{0}\n'.format(','.join(table_row)).decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

Requirements installation fails

When run pip install -r requirements.txt fails:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
launchpadlib 1.10.13 requires testresources, which is not installed.
awscli 1.25.37 requires botocore==1.27.37, but you have botocore 1.8.50 which is incompatible.
awscli 1.25.37 requires docutils<0.17,>=0.10, but you have docutils 0.19 which is incompatible.
awscli 1.25.37 requires s3transfer<0.7.0,>=0.6.0, but you have s3transfer 0.1.13 which is incompatible.
aws-list-all 0.8.0 requires boto3>=1.15.1, but you have boto3 1.5.14 which is incompatible.

My setup:

โžœ aws --version && python3 --version && lsb_release -a
aws-cli/1.25.37 Python/3.8.10 Linux/5.15.0-41-generic botocore/1.27.37
Python 3.8.10
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.4 LTS
Release:	20.04
Codename:	focal

Unhandled ResourceNotFoundException

 73% (11 of 15) |######################################################################################################################################                                                  | Elapsed Time: 0:00:15 ETA:  0:00:05Traceback (most recent call last):
  File "list_lambdas.py", line 230, in <module>
    print_lambda_list(args)
  File "list_lambdas.py", line 144, in print_lambda_list
    descending=True
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 317, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 615, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the DescribeLogStreams operation: The specified log group does not exist.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.