-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 65c71f9
Showing
11 changed files
with
798 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Publish AWS Lambda Layer Version | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
deploy: | ||
needs: build | ||
strategy: | ||
fail-fast: true | ||
|
||
update_readme: | ||
needs: deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist/sidecar-browsershot-layer.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Stefan Zweifel | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# sidecar-browsershot-layer | ||
AWS Lambda Layer used by sidecar-browsershot | ||
|
||
|
||
```shell | ||
sh bin/create-layer-zip.sh | ||
sh bin/publish-layer.sh | ||
``` | ||
|
||
|
||
```shell | ||
bun run build | ||
``` | ||
|
||
|
||
|
||
- `arn:aws:lambda:us-east-1:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:us-east-2:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:us-west-1:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:us-west-2:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:ca-central-1:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:eu-central-1:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:eu-west-1:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:eu-west-2:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:eu-west-3:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:eu-north-1:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:ap-northeast-1:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:ap-northeast-2:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:ap-southeast-1:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:ap-southeast-2:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:ap-south-1:821527532446:layer:sidecar-browsershot-layer:1` | ||
- `arn:aws:lambda:sa-east-1:821527532446:layer:sidecar-browsershot-layer:1` | ||
|
||
## Supported Regions | ||
|
||
- us-east-1 | ||
- us-east-2 | ||
- us-west-1 | ||
- us-west-2 | ||
- ca-central-1 | ||
- eu-central-1 | ||
- eu-west-1 | ||
- eu-west-2 | ||
- eu-west-3 | ||
- eu-north-1 | ||
- ap-northeast-1 | ||
- ap-northeast-2 | ||
- ap-southeast-1 | ||
- ap-southeast-2 | ||
- ap-south-1 | ||
- sa-east-1 | ||
|
||
|
||
```shell | ||
sh bin/create-buckets.sh <aws-cli-profile> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
# AWS Lambda Layer Name | ||
export LAYER_NAME="sidecar-browsershot-layer"; | ||
|
||
# Base S3 Bucket Name | ||
export S3_BUCKET_NAME="wnx-sidecar-layers"; | ||
|
||
# Supported AWS Regions | ||
export AWS_REGIONS="us-east-1 us-east-2 us-west-1 us-west-2 ca-central-1 eu-central-1 eu-west-1 eu-west-2 eu-west-3 eu-north-1 ap-northeast-1 ap-northeast-2 ap-southeast-1 ap-southeast-2 ap-south-1 sa-east-1"; | ||
|
||
export LOCAL_FILENAME="sidecar-browsershot-layer.zip"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/sh | ||
|
||
source "$(dirname "$0")/config.sh" | ||
|
||
PROFILE=$1; | ||
|
||
for REGION in $AWS_REGIONS; do | ||
BUCKET_NAME="$S3_BUCKET_NAME-$REGION"; | ||
|
||
aws configure set region $REGION; | ||
aws s3api create-bucket \ | ||
--bucket=$BUCKET_NAME \ | ||
--profile=$PROFILE \ | ||
--region=$REGION \ | ||
--create-bucket-configuration LocationConstraint=$REGION; | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/sh | ||
|
||
source "$(dirname "$0")/config.sh" | ||
|
||
rm -rf "./dist/$LOCAL_FILENAME"; | ||
|
||
# Delete not used TypeScript Types | ||
npx del-cli "./node_modules/**/@types/**" \ | ||
"./node_modules/**/*.d.ts" \ | ||
"./node_modules/**/.yarn-integrity" \ | ||
"./node_modules/**/.bin" \ | ||
"./node_modules/**/README.md" \ | ||
"./node_modules/agent-base/src/*.ts" \ | ||
"./**/.DS_Store" | ||
|
||
# Define the target folder name | ||
TARGET_FOLDER="nodejs" | ||
|
||
# Remove previous folder | ||
rm -rf "./dist/$TARGET_FOLDER" | ||
|
||
# Create the target folder if it doesn't exist | ||
mkdir -p "./dist/$TARGET_FOLDER" | ||
|
||
# Copy node_modules files to nested folder | ||
cp -R "./node_modules" "./dist/$TARGET_FOLDER/node_modules" | ||
|
||
# Change the working directory to the parent directory of node_modules | ||
cd "./dist/" | ||
|
||
# Zip the contents of node_modules and place it inside the target folder | ||
zip -r $LOCAL_FILENAME -9 "./$TARGET_FOLDER/node_modules/" | ||
|
||
# Return to the original directory | ||
cd - | ||
|
||
# Delete temporary folder name | ||
rm -rf "./dist/$TARGET_FOLDER" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/sh | ||
|
||
source "$(dirname "$0")/config.sh" | ||
|
||
PROFILE=$1; | ||
|
||
if [ -n "$PROFILE" ] | ||
then | ||
echo "Using Profile ${PROFILE} to create Lambda layer."; | ||
else | ||
echo "No Profile provided. Abort."; | ||
exit 1; | ||
fi | ||
|
||
# Extract exact dependency versions | ||
PUPPETEER_CORE_VERSION=$(npm list --json | jq -r '.dependencies."puppeteer-core".version'); | ||
|
||
# Generate Layer description | ||
LAYER_DESCRIPTION="puppeteer-core v$PUPPETEER_CORE_VERSION"; | ||
|
||
# Generate remote file name | ||
REMOTE_FILE_NAME="sidecar-browsershot-layer__puppeteer-core-v${PUPPETEER_CORE_VERSION}.zip"; | ||
REMOTE_FILE_PATH="sidecar-browsershot-layer/${REMOTE_FILE_NAME}"; | ||
|
||
LOCAL_FILE_PATH="dist/${LOCAL_FILENAME}"; | ||
|
||
for REGION in $AWS_REGIONS; do | ||
BUCKET_NAME="$S3_BUCKET_NAME-$REGION"; | ||
|
||
# Uplaod ZIP to S3 Bucket | ||
aws configure set region $REGION; | ||
aws s3 cp $LOCAL_FILE_PATH s3://$BUCKET_NAME/$REMOTE_FILE_PATH --profile=$PROFILE; | ||
|
||
# Publish new Layer Version | ||
NEW_VERSION_NUMBER=$(aws lambda publish-layer-version \ | ||
--region $REGION \ | ||
--layer-name $LAYER_NAME \ | ||
--description "$LAYER_DESCRIPTION" \ | ||
--content "S3Bucket=${BUCKET_NAME},S3Key=${REMOTE_FILE_PATH}" \ | ||
--compatible-runtimes nodejs \ | ||
--compatible-architectures x86_64 \ | ||
--output text \ | ||
--query Version \ | ||
--profile $PROFILE) | ||
|
||
# Update Layer Permission | ||
aws lambda add-layer-version-permission \ | ||
--region $REGION \ | ||
--layer-name $LAYER_NAME \ | ||
--statement-id sid1 \ | ||
--action lambda:GetLayerVersion \ | ||
--principal '*' \ | ||
--version-number $NEW_VERSION_NUMBER \ | ||
--profile=$PROFILE | ||
done |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"puppeteer-core": "^21.2.1" | ||
} | ||
} |
Oops, something went wrong.