Skip to content

Commit 3bd07c2

Browse files
committed
chore(readme): update readme
1 parent 3f428f9 commit 3bd07c2

File tree

2 files changed

+112
-7
lines changed

2 files changed

+112
-7
lines changed

README.md

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,112 @@
1-
## AWS Lambda Layer Release
2-
Your one stop AWS Lambda Layer Release Function.
1+
# Custom GitHub Action for Lambda Layer Release
2+
3+
![GitHub Action Version](https://img.shields.io/badge/version-v0.0.0-blue)
4+
![GitHub Action Workflow](https://img.shields.io/badge/workflow-CI/CD-green)
5+
![License](https://img.shields.io/badge/license-MIT-orange)
6+
7+
This GitHub Action simplifies the process of releasing AWS Lambda layers by automating the deployment and updating of Lambda functions that depend on the layer. It provides a seamless experience for releasing Lambda layers with a failsafe mechanism for larger layers, automatically handling uploads via an S3 bucket when needed.
8+
9+
## Features
10+
11+
1. **Seamless Lambda Layer Release:** This action streamlines the release process for AWS Lambda layers, making it easy and straightforward. With just a few configuration settings, you can deploy your layer effortlessly.
12+
13+
2. **Failsafe Mechanism for Larger Layers:** For larger Lambda layers that might exceed AWS Lambda's maximum layer size limit, this action automatically handles the upload via an S3 bucket. This ensures a smooth deployment process without any size-related issues.
14+
15+
3. **Update Dependent Lambdas:** When you release a new version of the Lambda layer, this action provides an option to automatically update the configuration of all Lambda functions that utilize this layer. This helps in keeping all Lambda functions up-to-date with the latest layer version.
16+
17+
## Usage
18+
19+
To use this action in your workflow, you need to create a workflow file (e.g., `.github/workflows/release_layer.yml`) and add the following steps:
20+
21+
```yaml
22+
name: Release Lambda Layer
23+
24+
on:
25+
push:
26+
branches:
27+
- main
28+
29+
jobs:
30+
release:
31+
name: Release Layer
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout Code
35+
uses: actions/checkout@v2
36+
37+
- name: Release Lambda Layer
38+
uses: theserverfault/[email protected]
39+
with:
40+
access_key_id: ${{ secrets.AWS_DEV_ACCESS_KEY_ID }}
41+
secret_access_key: ${{ secrets.AWS_DEV_SECRET_ACCESS_KEY }}
42+
layer_name: <LAYER_NAME>
43+
archive: nodejs.zip
44+
architectures: '["x86_64"]'
45+
runtimes: '["nodejs16.x","nodejs18.x"]'
46+
s3_bucket: '<S3_BUCKET_NAME>'
47+
functions: '["<LAMBDA_NAME1>", <LAMBDA_NAME2>]'
48+
```
49+
Replace the placeholders with the appropriate values:
50+
51+
- `access_key_id`: AWS Access Key Id (Recommeneded to save this safely in secrets)<br/>
52+
- `secret_access_key`: AWS Secret Access Key (Recommeneded to save this safely in secrets)<br/>
53+
- `layer_name`: Name of the layer where you want to publish this version. This layer name must already exist on AWS Lambda layers.`access_key_id` and `secret_access_key` must be allowed to interact with this layer.<br/>
54+
- `archive`: Refers the path of the zip archive to upload as layer. The archive creation process is not part of this action since the build steps may vary from application to application and it should be taken care as a separate step. Refer below for a quick example to how to do this for a NodeJS application.<br/>
55+
- `architectures`: String containing array of architectures that this new layer will support. Valid values are `[x_86_64 || arm64]`.<br/>
56+
- `runtimes`: The list of valid runtimes that this layer can support. The valid values are `["nodejs" || "nodejs4.3" || "nodejs6.10" || "nodejs8.10" || "nodejs10.x" || "nodejs12.x" || "nodejs14.x" || "nodejs16.x" || "java8" || "java8.al2" || "java11" || "python2.7" || "python3.6" || "python3.7" || "python3.8" || "python3.9" || "dotnetcore1.0" || "dotnetcore2.0" || "dotnetcore2.1" || "dotnetcore3.1" || "dotnet6" || "nodejs4.3-edge" || "go1.x" || "ruby2.5" || "ruby2.7" || "provided" || "provided.al2" || "nodejs18.x" || "python3.10" || "java17" || "ruby3.2" || "python3.11"]`<br/>
57+
- `s3_bucket`: An optional parameter for S3 Bucket Name In case if layer exceeds the allocated threshold size. We recommend to always provide with this value since if this value is present then action will try to upload layer via S3 automatically as failsafe mechanism for larger layers. Overcoming the limitation of direct AWS Lambda Layer size constraints over SDK.
58+
- `functions`: An Optional array of functions to refresh the layer to the latest uploaded version. It is recommended to pass down all the functions in this argument that uses this layer. Action will try to refresh all the dependent functions to use the latest layer version automatically.
59+
60+
This GitHub Action is distributed under the MIT License. See LICENSE for more information.
61+
62+
## Example
63+
This example demonstrated generating the archive and then publishing the layer via this githb action
64+
```yaml
65+
name: Release Layer
66+
67+
on:
68+
push:
69+
branches: [main]
70+
paths: ["package.json"]
71+
72+
jobs:
73+
build:
74+
if: "!contains(github.event.head_commit.message, '[skip-ci]')"
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@v2
78+
- name: Install Nodejs
79+
uses: actions/setup-node@v3
80+
with:
81+
node-version: 18
82+
- name: Install Dependencies, Build application and Zip dist file
83+
run: yarn install --frozen-lockfile
84+
- name: Bundle the layer zip
85+
run: mkdir nodejs
86+
- run: mv package.json nodejs/
87+
- run: mv yarn.lock nodejs/
88+
- run: mv node_modules nodejs/
89+
90+
- name: Packing up the zip file
91+
run: zip -r nodejs.zip -r nodejs
92+
93+
- name: Publish Layer
94+
uses: theserverfault/[email protected]
95+
with:
96+
access_key_id: ${{ secrets.AWS_DEV_ACCESS_KEY_ID }}
97+
secret_access_key: ${{ secrets.AWS_DEV_SECRET_ACCESS_KEY }}
98+
layer_name: my-custom-layer
99+
archive: nodejs.zip
100+
architectures: ["x86_64"]
101+
runtimes: ["nodejs16.x","nodejs18.x"]
102+
s3_bucket: my-layers-bucket
103+
functions: ["function1-using-layer", "function2-using-layer"]
104+
```
105+
106+
## Contributions
107+
108+
Contributions to this project are welcome. If you find any issues or want to add new features, feel free to submit a pull request.
109+
110+
By using this custom GitHub Action, you can simplify the release process of your AWS Lambda layers, automate the handling of larger layers, and ensure all dependent Lambda functions are updated with the latest layer version. Happy coding!
111+
112+
> Stay tuned to wonderful tech content at https://theserverfault.com

helper.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,5 @@ exports.refreshLambdaLayerVersion = async ({
144144
})));
145145

146146
const response = await Promise.all(commands);
147-
if (errored(response)) {
148-
console.log(JSON.stringify(response));
149-
throw new Error("Error While Refreshing Lambda For Latest Layer. If you feel this is a bug, raise a ticket on the repo.");
150-
}
151-
console.log("Refreshing Lambda For Latest Layer.");
152147
return response;
153148
}

0 commit comments

Comments
 (0)