Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
linux_wiki:lambda_python_function [2019/07/31 20:50] billdozor [Lambda: Package and Upload Function] |
linux_wiki:lambda_python_function [2019/08/09 22:13] billdozor [Lambda: Pre-Reqs] |
||
---|---|---|---|
Line 18: | Line 18: | ||
See below for Lambda examples. | See below for Lambda examples. | ||
* File Conversion Example - convert images from one format to another when created in a S3 bucket. | * File Conversion Example - convert images from one format to another when created in a S3 bucket. | ||
+ | * Stop/Start EC2 Instances Example - stop/start ec2 instances with a certain tag key:value on a schedule. | ||
Line 39: | Line 40: | ||
" | " | ||
" | " | ||
- | " | + | " |
+ | " | ||
], | ], | ||
" | " | ||
Line 46: | Line 48: | ||
" | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
- | " | + | |
- | | + | |
- | ], | + | |
" | " | ||
} | } | ||
Line 104: | Line 102: | ||
===== File Conversion Example: Packaging ===== | ===== File Conversion Example: Packaging ===== | ||
- | * Create the directory and python3 virtual environment<code bash> | + | * Create |
- | cd convertImage | + | |
- | python3 -m venv venv</ | + | |
- | * Activate the virtualenv and install | + | * Install |
- | pip install | + | |
- | * Create the lambda function file< | + | * Create the lambda function file< |
import json | import json | ||
Line 123: | Line 118: | ||
* **Notes** | * **Notes** | ||
* The above is the default code that is created for you in a from scratch lambda function in the console. | * The above is the default code that is created for you in a from scratch lambda function in the console. | ||
- | * For the File conversion example and others, see: https:// | + | * For the File conversion example and others, see: https:// |
+ | |||
+ | * Package up the directory into a zip<code bash>cd convertImage | ||
+ | zip -r convertImage.zip .</ | ||
+ | * **Important**: | ||
- | * Package up the directory into a zip | + | * Upload to AWS Lambda |
+ | * CLI Method< | ||
+ | * Web Console Method | ||
+ | * Login to your AWS console | ||
+ | * Services > Compute > Lambda | ||
+ | * Click " | ||
+ | * Under " | ||
+ | * Click the dropdown and select " | ||
+ | * Under " | ||
+ | * Browse to your file and select it | ||
+ | * In the top right, click " | ||
---- | ---- | ||