Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
brunocalderon committed Oct 25, 2019
0 parents commit e5bf5d9
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patreon: springsdigital
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Springs Digital SpA. https://springsdigital.com

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.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# LayerizeJS
A set of bash scripts from [Springs Digital](https://springsdigital.com) to automate the creation, update and upload of Lambda Layers in Node.js

### Installation
Simply get the files via the terminal
```
curl 'https://raw.githubusercontent.com/springsdigital/layerizejs/master/create_layer.sh' > create_layer.sh && \
curl 'https://raw.githubusercontent.com/springsdigital/layerizejs/master/update_layer.sh' > update_layer.sh
```

## Usage

### Creating a new layer

Use `bash create_layer.sh` to create a new layer.
The script will ask for the package name.
If the package is scoped, you will have to provide the scoped name (ex: @scope/package)

### Updating a layer
Use `bash update_layer.sh` to update a layer.
You will need to provide the module name. If the module is scoped, provide the module name without scope (ex: ~~@scope/~~ **package**)

> It's important to note that you previously need to have the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) installed and configured.
## Credits

Thank you [contributors](https://github.com/springsdigital/layerizejs/graphs/contributors)!

<img src="https://static.springsdigital.com/logo.png" alt="Springs Digital" width="250"/>

LayerizeJS is maintained by [Springs Digital](https://springsdigital.com).

## License

LayerizeJS is © of Springs Digital Spa. It is free software and may be redistributed under the terms specified in the [LICENSE](https://github.com/springsdigital/layerizejs/blob/master/LICENSE).
48 changes: 48 additions & 0 deletions create_layer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
read -p "What's the package name?: " packagename
if [ -d "$packagename" ]
then
echo "This lambda layer already exists, use upload_layer.sh"
exit 1
fi
echo "Creating a lambda layer package for $packagename"
mkdir "$packagename"
cd "$packagename"
mkdir nodejs
cd nodejs
npm init -y >/dev/null
printf "\033[1;32mCreated package.json ✔\033[0m\n"
echo "Is the package scoped?"
read -p "[Y/n]:" scoped
if [ $scoped = Y ] || [ $scoped = y ] || [ $scoped = Yes ] || [ $scoped = yes ]
then
echo "Provide the full package with scope. Example: @scope/package"
read -p "@scope/package: " scopedpackage
echo "This is a scoped package. Installing $scopedpackage"
npm i $scopedpackage &>/dev/null
printf "\033[1;32mInstalled $scopedpackage ✔\033[0m\n"
else
echo "This is a not scoped package. Installing $packagename"
npm i $packagename &>/dev/null
printf "\033[1;32mInstalled $packagename ✔\033[0m\n"
fi
cd ..
zip -r nodejs.zip nodejs/ >/dev/null
printf "\033[1;32mLayer created ✔\033[0m\n"
echo "Do you want to upload the layer?"
read -p "[Y/n]:" upload
if [ $upload = Y ] || [ $upload = y ] || [ $upload = Yes ] || [ $upload = yes ]
then
echo "Uploading layer"
aws lambda publish-layer-version --zip-file fileb://nodejs.zip --cli-input-json '{
"LayerName": "'$packagename'",
"Description": "'$packagename' for nodejs",
"CompatibleRuntimes": [
"nodejs10.x"
]
}' >/dev/null
printf "\033[1;32mUploaded ✔\033[0m\n"
echo "The $packagename lambda layer was successfully created and uploaded"
else
echo "Goodbye"
fi
32 changes: 32 additions & 0 deletions update_layer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
read -p "What's the layer name (without lambda-layer-nodejs)?: " packagename
echo "Updating a lambda layer package for $packagename"
cd "$packagename"
cd nodejs
npm update >/dev/null
printf "\033[1;32mUpdated ✔\033[0m\n"
echo "Packing layer"
cd ..
if [ -f nodejs.zip ]
then
rm nodejs.zip >/dev/null
fi
zip -r nodejs.zip nodejs/ >/dev/null
printf "\033[1;32mPacked ✔\033[0m\n"
echo "Do you want to upload the layer?"
read -p "[Y/n]:" upload
if [ $upload = Y ] || [ $upload = y ] || [ $upload = Yes ] || [ $upload = yes ]
then
echo "Uploading layer"
aws lambda publish-layer-version --zip-file fileb://nodejs.zip --cli-input-json '{
"LayerName": "'$packagename'",
"Description": "'$packagename' for nodejs",
"CompatibleRuntimes": [
"nodejs10.x"
]
}' >/dev/null
printf "\033[1;32mUploaded ✔\033[0m\n"
echo "The $packagename lambda layer was successfully updated and uploaded"
else
echo "Goodbye"
fi

0 comments on commit e5bf5d9

Please sign in to comment.