|
| 1 | +# AWS Lambda Function List Python example |
| 2 | + |
| 3 | +This folder contains a Python application example that handles Lambda functions on AWS (Amazon Web Services). |
| 4 | + |
| 5 | +List all Lambda functions and their information using the Client API (low-level) of Boto 3. |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +* You must have an [Amazon Web Services (AWS)](http://aws.amazon.com/) account. |
| 10 | + |
| 11 | +* The code was written for Python 3 and AWS SDK for Python (Boto3). |
| 12 | + |
| 13 | +* This example uses Client API (low-level) of Boto 3. |
| 14 | + |
| 15 | +* Install the AWS SDK for Python (Boto3). |
| 16 | + |
| 17 | + Install the latest Boto 3 release via pip: |
| 18 | + |
| 19 | + ```bash |
| 20 | + pip install boto3 |
| 21 | + ``` |
| 22 | + |
| 23 | +## Using the code |
| 24 | + |
| 25 | +* Configure your AWS access keys. |
| 26 | + |
| 27 | + **Important:** For security, it is strongly recommend that you use IAM users instead of the root account for AWS access. |
| 28 | + |
| 29 | + When you initialize a new service client without supplying any arguments, the AWS SDK for Java attempts to find AWS credentials by using the default credential provider chain. |
| 30 | + |
| 31 | + Setting your credentials for use by the AWS SDK for Java can be done in a number of ways, but here are the recommended approaches: |
| 32 | + |
| 33 | + * The default credential profiles file |
| 34 | + |
| 35 | + Set credentials in the AWS credentials profile file on your local system, located at: |
| 36 | + |
| 37 | + `~/.aws/credentials` on Linux, macOS, or Unix |
| 38 | + |
| 39 | + `C:\Users\USERNAME\.aws\credentials` on Windows |
| 40 | + |
| 41 | + This file should contain lines in the following format: |
| 42 | + |
| 43 | + ```bash |
| 44 | + [default] |
| 45 | + aws_access_key_id = <your_access_key_id> |
| 46 | + aws_secret_access_key = <your_secret_access_key> |
| 47 | + ``` |
| 48 | + Substitute your own AWS credentials values for the values `<your_access_key_id>` and `<your_secret_access_key>`. |
| 49 | + |
| 50 | + * Environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` |
| 51 | + |
| 52 | + Set the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. |
| 53 | + |
| 54 | + To set these variables on Linux, macOS, or Unix, use `export`: |
| 55 | + |
| 56 | + ```bash |
| 57 | + export AWS_ACCESS_KEY_ID=<your_access_key_id> |
| 58 | + export AWS_SECRET_ACCESS_KEY=<your_secret_access_key> |
| 59 | + ``` |
| 60 | + |
| 61 | + To set these variables on Windows, use `set`: |
| 62 | + |
| 63 | + ```bash |
| 64 | + set AWS_ACCESS_KEY_ID=<your_access_key_id> |
| 65 | + set AWS_SECRET_ACCESS_KEY=<your_secret_access_key> |
| 66 | + ``` |
| 67 | + |
| 68 | +* You can create a Lambda function on AWS. |
| 69 | + |
| 70 | + You can use the AWS Lambda Function Hello World JSON Java example: [awslambdahellojson](/awslambdahellojson). |
| 71 | + |
| 72 | +* You can select the bucket region changing the value of `REGION` variable in the code. |
| 73 | + |
| 74 | +* Run the code. |
| 75 | + |
| 76 | + Run application: |
| 77 | + |
| 78 | + ```bash |
| 79 | + python lambdalistall.py |
| 80 | + ``` |
| 81 | + |
| 82 | +* Test the application. |
| 83 | + |
| 84 | + You should see the list of all Lambda functions and their information. |
0 commit comments