Skip to content

Commit

Permalink
feat(lambda): add a layer for lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Jun 22, 2022
1 parent 35b0c1b commit a540fed
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 239 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ lambdas
*.plan
*.tfstate.d
*.credentials.json
lambda_layer.zip
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
".terraform",
"*.plan",
"*.tfstate.d",
"*.credentials.json"
"*.credentials.json",
"lambda_layer.zip"
],
"rootPackage": true
}
Expand Down
3 changes: 2 additions & 1 deletion packages/whook-create/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/whook-create/src/services/createWhook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ Mr Bean
"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.1.0",
"jsarch": "^5.0.1",
"openapi-schema-validator": "^11.0.1",
"parse-gitignore": "^1.0.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
Expand Down Expand Up @@ -399,6 +400,7 @@ Mr Bean
"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.1.0",
"jsarch": "^5.0.1",
"openapi-schema-validator": "^11.0.1",
"parse-gitignore": "^1.0.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
Expand Down Expand Up @@ -606,6 +608,7 @@ Mr Bean
"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.1.0",
"jsarch": "^5.0.1",
"openapi-schema-validator": "^11.0.1",
"parse-gitignore": "^1.0.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
Expand Down
6 changes: 6 additions & 0 deletions packages/whook-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ Build the lambdas:
NODE_ENV=staging npm run build
```

Build the lambdas layer:

```sh
NODE_ENV=staging bin/lambda_layer.sh
```

Build the commands Terraform depends on:

```sh
Expand Down
7 changes: 7 additions & 0 deletions packages/whook-example/bin/lambda_layer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mkdir -p layer/nodejs;
cp package.json layer/nodejs/package.json;
cp package-lock.json layer/nodejs/package-lock.json;
docker run --entrypoint "" -v "$PWD/layer/nodejs":/var/task "public.ecr.aws/lambda/nodejs:14" /bin/sh -c "yum install -y gcc gcc-c++ make; npm i --production; sudo chown -R $USER /var/task; exit";
env --chdir "$PWD/layer" zip -r ../lambda_layer.zip .;
docker run --entrypoint "" -v "$PWD/layer/nodejs":/var/task "public.ecr.aws/lambda/nodejs:14" /bin/sh -c "rm -rf node_modules; exit";
rm -rf layer/nodejs;
71 changes: 53 additions & 18 deletions packages/whook-example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/whook-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
".terraform",
"*.plan",
"*.tfstate.d",
"*.credentials.json"
"*.credentials.json",
"lambda_layer.zip"
],
"bundleFiles": [
"bin",
Expand Down Expand Up @@ -120,6 +121,7 @@
"jsarch": "^5.0.1",
"metapak": "^4.0.4",
"metapak-nfroidure": "12.1.0",
"openapi-schema-validator": "^11.0.1",
"parse-gitignore": "^1.0.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
Expand Down
Loading

0 comments on commit a540fed

Please sign in to comment.