Les comparto algunos scripts de los comandos que miramos en la clase, y otros links de referencias de la clase, espero que les sirvan!
<h5>Script para crear layer</h5>#!/bin/bash
npm i --omit=dev
mkdir nodejs/
mv node_modules/ nodejs/
zip -r nodejs-layer.zip nodejs/
rm -rf nodejs/
<h5>Script para subir layer</h5>
#!/bin/bash
aws lambda publish-layer-version --layer-name my-first-layer \
--description "My first layer for lambda with nodejs" \
--license-info "MIT" \
--zip-file fileb://nodejs-layer.zip \
--compatible-runtimes nodejs18.x \
--compatible-architectures x86_64 \
<h5>serverless.yml</h5>
...
package:
individually: true
patterns:
- "!**"
...
functions:
...
signedUrl:
handler: src/signedUrl/handler.signedUrl
name: signedUrl
description: Obtain signedUrl to upload s3 bucket object
package:
patterns:
- src/signedUrl/**/*.js
layers:
- !Ref BaseLambdaLayer
memorySize: 128
runtime: nodejs18.x
architecture: x86_64
timeout: 15
events:
- http:
path: signedUrl
method: GET
request:
parameters:
querystrings:
filename: true
...
layers:
base:
name: prd-dependencies
description: layer for nodejs prd dependencies
licenseInfo: MIT
compatibleRuntimes:
- nodejs18.x
compatibleArchitectures:
- x86_64
package:
artifact: nodejs-layer.zip
<h5>Resources</h5>
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?