Coder Social home page Coder Social logo

aws-lambda-layers-example's Introduction

AWS Layers Walk-through

Docs: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html

Aim: Make a lambda whose job is to just call code from the layer

brew bundle
yarn install
cd layer; yarn install; cd ..

Set up the Peril aws cli env (make sure to set the region)

aws configure --profile peril

AWS Access Key ID [****************L7UA]:
AWS Secret Access Key [****************HH9A]:
Default region name [us-east-1]:
Default output format [json]:

Make and bundle app code

touch index.js
# edit it
rm dist/function.zip; cd app; zip ../dist/function.zip index.js; cd ..

Make (or get) AWS Role - https://console.aws.amazon.com/iam/home?#/roles

aws lambda create-function --function-name helloworld \
--zip-file fileb://./dist/function.zip --handler index.handler --runtime nodejs8.10 \
--role arn:aws:iam::656992703780:role/lambda-cli-role --profile peril

This makes a lambda. Add a layer runtime:

rm dist/layer.zip; cd layer; zip ../dist/layer.zip -r *; cd ..
aws lambda publish-layer-version --layer-name underscore-runtime --zip-file fileb://dist/layer.zip --profile peril

Now add it to the helloworld lambda:

aws lambda update-function-configuration --function-name helloworld --layers arn:aws:lambda:us-east-1:656992703780:layer:underscore-runtime:1 --profile peril

Now to update your lambda:

aws lambda update-function-code --function-name helloworld --zip-file fileb://./dist/function.zip  --profile peril

Invoke it:

aws lambda invoke --function-name helloworld dist/output.log --profile peril

From there, any updates to the layers will need to be re-applied to the functions. This is kinda cool, because in theory different folks could have different Peril runtimes.


You should be able to see:

In the Dashboard.

Misc notes:

  • preview a zip: unzip -l dist/app.zip

aws-lambda-layers-example's People

Contributors

orta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

alexrogalskiy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.