Giter VIP home page Giter VIP logo

lambda-podbooster's Introduction

lambda-podbooster

Here's a basic breakdown of the folder structure for this repo:

.
├── README.md                   <-- This instructions file
├── podbooster                  <-- Source code for a lambda function
│   ├── index.js                <-- Lambda function code
│   ├── package.json            <-- NodeJS dependencies
│   └── tests                   <-- Unit tests
│       └── unit
│           └── test_handler.js
└── template.yaml               <-- SAM template

Requirements

Setup process

Building the project

AWS Lambda requires a flat folder with the application as well as its dependencies in a node_modules folder. When you make changes to your source code or dependency manifest, run the following command to build your project local testing and deployment:

sam build --use-container

By default, this command writes built artifacts to .aws-sam/build folder.

Local development

Invoking function locally through local API Gateway

sam local start-api

If the previous command ran successfully you should now be able to hit the following local endpoint to invoke your function http://localhost:3000/podbooster

Testing

We use mocha for testing our code and it is already added in package.json under scripts, so that we can simply run the following command to run our tests:

cd podbooster
npm install
npm run test

Why docker?

Because differences in machine architecture, the files to be uploaded to lambda (like node_modules) must all be built in an Amazon Linux 2 Docker container so that the Lame bindings work in lambda.

Steps to develop:

  1. build the docker image locally: docker build -f Dockerfile . -t scprdev/lambda-podbooster
  2. run the image: docker run -v path/to/this/repo/podbooster:/working -it scprdev/lambda-podbooster:latest
  3. note in the previous step that the path is to the podbooster directory in this current repo, not the repo root. We're mapping that to the '/working` directory in the docker container.
  4. the previous docker run command should have created a new lambda.zip file in the repo root (check the timestamp to verify)
  5. run ./publish.sh to publish that lambda.zip to AWS lambda

lambda-podbooster's People

Contributors

arellatv avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.