arellaTV / lambda-podbooster

A tool that lets you boost the volume of any podcast rss feed and upload to s3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

A tool that lets you boost the volume of any podcast rss feed and upload to s3


Languages

Language:JavaScript 94.7%Language:Shell 3.1%Language:Dockerfile 2.2%