|
1 | 1 | # Bash in AWS Lambda
|
2 | 2 |
|
3 |
| -Run Bash in AWS Lambda via Layers. This Layer is 100% Bash and handles all communication with the Lambda API. This allows you to run full Bash scripts and commands inside of AWS Lambda. This Layer also includes common CLI tools used in Bash scripts. |
| 3 | +Run Bash in [AWS Lambda](https://aws.amazon.com/lambda/) via [Layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html). This Layer is 100% Bash and handles all communication with the Lambda API. This allows you to run full Bash scripts and commands inside of AWS Lambda. This Layer also includes common CLI tools used in Bash scripts. |
| 4 | + |
| 5 | +See the [How To](README.md#HOWTO) section to understand how to use these layers. Also see the [example.sh](example.sh) file for an example of how to write a Bash script compatible with AWS Lambda. |
4 | 6 |
|
5 | 7 | ## How To
|
6 | 8 |
|
7 |
| -#### Caveats |
| 9 | +### Getting Started |
| 10 | + |
| 11 | +#### AWS Lambda Console |
| 12 | + |
| 13 | +1. Login to your AWS Account and go to the Lambda Console. |
| 14 | +2. Create a new function and give it a name and an IAM Role. |
| 15 | +3. For the "Runtime" selection, select `Use custom runtime in function code or layer`. |
| 16 | +4. In the "Designer" section of your function dashboard, select the `Layers` box. |
| 17 | +5. Scroll down to the "Referenced Layers" section and click `Add a layer`. |
| 18 | +6. Select the `Provide a layer version ARN` option, then copy/paste the [Layer ARN](README.md#ARNs) for your region. |
| 19 | +7. Click the `Add` button. |
| 20 | +8. Click `Save` in the upper right. |
| 21 | +9. Upload your code and start using Bash in AWS Lambda! |
| 22 | + |
| 23 | +#### AWS CLI |
| 24 | + |
| 25 | +1. Create a function that uses the `provided` runtime and the [Layer ARN](README.md#ARNs) for your region. |
| 26 | + |
| 27 | +``` |
| 28 | +$ aws lambda create-function \ |
| 29 | + --function-name bashFunction \ |
| 30 | + --role bashFunctionRole \ |
| 31 | + --handler index.handler \ |
| 32 | + --runtime provided \ |
| 33 | + --layers $ARN |
| 34 | +``` |
| 35 | + |
| 36 | +2. Upload your code and start using Bash in AWS Lambda! |
| 37 | + |
| 38 | +### Updating Versions |
| 39 | + |
| 40 | +#### AWS Lambda Console |
| 41 | + |
| 42 | +1. In the "Designer" section of your function dashboard, select the `Layers` box. |
| 43 | +2. Scroll down to the "Referenced Layers" section and click `Add a layer`. |
| 44 | +3. Select the `Provide a layer version ARN` option, then copy/paste the [Layer ARN](README.md#ARNs) for your region. |
| 45 | +4. Click the `Add` button. |
| 46 | +5. Still under the "Referenced Layers" section, select the previous version and click `Remove`. |
| 47 | +6. Click `Save` in the upper right. |
| 48 | + |
| 49 | + |
| 50 | +#### AWS CLI |
| 51 | + |
| 52 | +1. Update your function's configration and add the [Layer ARN](README.md#ARNs) for your region. |
| 53 | + |
| 54 | +``` |
| 55 | +$ aws lambda update-function-configuration \ |
| 56 | + --function-name bashFunction \ |
| 57 | + --layers $ARN |
| 58 | +``` |
| 59 | + |
| 60 | +### Caveats |
8 | 61 |
|
9 | 62 | Bash behaves in ways unlike other programming languages. As such, there are some requirements on the user's end that must be done.
|
10 | 63 |
|
|
0 commit comments