A few of the sample AWS Lambda function codes for common use-cases with Amazon EC2, AWS Lambda, API Gateway & Amazon SNS using Python runtime.
-
Delete EBS volumes using a snapshot and its status - delete_volumes_by_snapshot.py
-
Delete EBS volumes by snapshot - delete_volumes_by_snapshot.py
-
Describe all AMIs for your account across all regions - describe_ami.py
-
Describe EC2's metadata in a region - Associated subnets, Instance ID & NACL ID for a target VPC - describe_ec2_securitygroup.py
-
Start/Stop EC2 instances using CloudWatch Event Trigger - start_stop_ec2_instances_with_cloudwatch_event.py
-
Get all async configuration (Max retry attempts, max event age, destinations) across all regions - async_config_dashboard.py
-
Delete orphaned Event Source Mappings - clean_orphaned_event_source_mappings.py
-
Extract Lambda code from entire deployment package - extract_deployment_package_without_layers
-
Check Async queue congestions and delays in processing async events - get_async_invoke_delay.py
-
Get underlying Lambda's CPU hardware, /tmp storage, os-release and it's contents - get_cpu_info.py
-
Test HTTP connection for your Lambda function inside VPC - http_connection_test.py
-
List code storage for all Lambda functions in a region - lambda_code_size_all_functions.py
-
List code storage for a function including all attached layers - lambda_code_size_including_layers.py
-
List all ENIs created by Lambda functions(s) - lambda_created_enis.py
-
Get Lambda dashboard metrics across all regions - lambda_dashboard.py
-
List Lambda function version(s) using an ENI - lambda_hyperplane_eni_checker.py
-
Create "Memory Used" Metrics for your Lambda functions - lambda_memory_plot.py
-
Get all functions using reserved or provisional concurrency in a region - list_concurrency_functions.py
-
List Lambda functions using a runtime - list_functions_by_a_runtime
-
List all Lambda layers and it's info - list_layer_info.py
-
Use python modules from layers over deployment package - use_modules_from_layers
-
Lambda X-Ray examples - x_ray_sample.py
-
List all subscriptions tied to a topic in an account - list_account_topic_subscriptions.py
-
Programmatically create subscription filters for SNS - set_subscription_filters.py
-
Programmatically set SenderID while sending SMS text messages - sender_id.py
-
Programmatically set max price while sending SMS text messages - set_max_price.py
-
Get SMS month to date spend in USD - sms_month_to_date_spent_usd.py
-
SMS Dashboard - sms_dashboard.py
-
Send SMS with custom originating number - sms_with_custom_originating_number
- Upload Binary Image to S3 using a POST request - upload_image_to_s3.py
- Refer to the individual .md files for additional information.
-
๐ฐ Something broken? Open an issue with a few sample inputs where it breaks. Screenshots help!
-
More additional services/use-cases, open a new issue
This is an iterative repository, I'll keep adding more sample codes for more use-cases as I come across them. I have tested all scripts using Python3.6
runtime inside Lambda under us-west-2
region, and most of this should work for all Python3
runtime.
- Fork repo
- Set runtime as
Python3
(Python3.7
preferred) - Send your awesome ๐ Pull Request with code/.md changes
- Follow Python's PEP8 coding standards.
- Commit repo using the Seven Rules
- Your PR gets merged โ and a shout out ๐ข
$ tree
.
โโโ CODE_OF_CONDUCT.md
โโโ LICENSE
โโโ README.md
โโโ api-gateway-samples
โย ย โโโ upload_image_to_s3
โย ย โโโ README.md
โย ย โโโ template.yml
โย ย โโโ upload_image_to_s3.py
โโโ ec2-samples
โย ย โโโ delete_older_snapshots
โย ย โย ย โโโ README.md
โย ย โย ย โโโ delete_older_snapshots.py
โย ย โโโ delete_volumes_by_snapshot
โย ย โย ย โโโ README.md
โย ย โย ย โโโ delete_volumes_by_snapshot.py
โย ย โโโ describe_ami
โย ย โย ย โโโ README.md
โย ย โย ย โโโ describe_ami.py
โย ย โโโ describe_ec2_securitygroup
โย ย โย ย โโโ README.md
โย ย โย ย โโโ describe_ec2_securitygroup.py
โย ย โโโ start_stop_ec2_instances_with_cloudwatch_event
โย ย โโโ README.md
โย ย โโโ start_stop_ec2_instances_with_cloudwatch_event.py
โโโ lambda-layer
โย ย โโโ README.md
โย ย โโโ boto3.zip
โย ย โโโ pandasnumpy.zip
โย ย โโโ prettyTable.zip
โย ย โโโ psycopg2.zip
โย ย โโโ python38+
โย ย โย ย โโโ boto3_python38+.zip
โย ย โย ย โโโ numpy_pandas_scipy_python38+.zip
โย ย โย ย โโโ requests_python38+.zip
โย ย โย ย โโโ urllib3_python38+.zip
โย ย โโโ requests.zip
โย ย โโโ urllib3.zip
โย ย โโโ x-ray.zip
โโโ lambda-samples
โย ย โโโ async_config_dashboard
โย ย โย ย โโโ README.md
โย ย โย ย โโโ async_config_dashboard.py
โย ย โโโ clean_orphaned_event_source_mappings
โย ย โย ย โโโ README.md
โย ย โย ย โโโ clean_orphaned_event_source_mappings.py
โย ย โโโ extract_deployment_package_without_layers
โย ย โย ย โโโ README.md
โย ย โย ย โโโ extract_deployment_package_without_layers.py
โย ย โโโ get_async_invoke_delay
โย ย โย ย โโโ README.md
โย ย โย ย โโโ get_async_invoke_delay.py
โย ย โโโ get_cpu_info
โย ย โย ย โโโ README.md
โย ย โย ย โโโ get_cpu_info.py
โย ย โโโ http_connection_test
โย ย โย ย โโโ README.md
โย ย โย ย โโโ http_connection_test.py
โย ย โโโ lambda_code_size_all_functions
โย ย โย ย โโโ README.md
โย ย โย ย โโโ lambda_code_size_all_functions.py
โย ย โโโ lambda_code_size_including_layers
โย ย โย ย โโโ README.md
โย ย โย ย โโโ lambda_code_size_including_layers.py
โย ย โโโ lambda_created_enis
โย ย โย ย โโโ README.md
โย ย โย ย โโโ lambda_created_enis.py
โย ย โโโ lambda_dashboard
โย ย โย ย โโโ README.md
โย ย โย ย โโโ lambda_dashboard.py
โย ย โโโ lambda_hyperplane_eni_checker
โย ย โย ย โโโ README.md
โย ย โย ย โโโ lambda_hyperplane_eni_checker.py
โย ย โโโ lambda_memory_plot
โย ย โย ย โโโ README.md
โย ย โย ย โโโ lambda_memory_plot.py
โย ย โโโ list_concurrency_functions
โย ย โย ย โโโ README.md
โย ย โย ย โโโ list_concurrency_functions.py
โย ย โโโ list_functions_by_a_runtime
โย ย โย ย โโโ README.md
โย ย โย ย โโโ list_functions_by_a_runtime.py
โย ย โโโ list_layer_info
โย ย โย ย โโโ README.md
โย ย โย ย โโโ list_layer_info.py
โย ย โโโ use_modules_from_layers
โย ย โย ย โโโ README.md
โย ย โย ย โโโ use_modules_from_layers.py
โย ย โโโ x_ray_sample
โย ย โโโ README.md
โย ย โโโ x_ray_sample.py
โโโ sns-samples
โย ย โโโ list_account_topic_subscriptions
โย ย โย ย โโโ README.md
โย ย โย ย โโโ list_account_topic_subscriptions.py
โย ย โโโ sender_id
โย ย โย ย โโโ README.md
โย ย โย ย โโโ sender_id.py
โย ย โโโ set_max_price_sms
โย ย โย ย โโโ README.md
โย ย โย ย โโโ set_max_price_sms.py
โย ย โโโ set_subscription_filters
โย ย โย ย โโโ README.md
โย ย โย ย โโโ set_subscription_filters.py
โย ย โโโ sms_dashboard
โย ย โย ย โโโ README.md
โย ย โย ย โโโ sms_dashboard.py
โย ย โโโ sms_month_to_date_spent_usd
โย ย โย ย โโโ README.md
โย ย โย ย โโโ sms_month_to_date_spent_usd.py
โย ย โโโ sms_with_custom_originating_number
โย ย โโโ README.md
โย ย โโโ sms_with_custom_originating_number.py
โโโ tmp
โโโ images
โโโ AWSLambdaAsyncDelayCloudWatchInsights.png
โโโ AWSLambdaCloudWatchAsyncDelay.png
โโโ AWSLambdaCloudWatchMetric.png
โโโ AWSLambdaX-Ray.PNG