Sign inSign up

hitfox/sqs-pipeline-lambdas-node-source

By hitfox

•Updated over 10 years ago

sqs-pipeline-lambdas-node-source

Image
0

425

hitfox/sqs-pipeline-lambdas-node-source repository overview

⁠data-pipeline-lambda source docker image

This image is the base for nodejs code in data-pipelines. This is the repository for source-lambdas in nodejs

⁠Installation

The basic setup consists of a index.js and a Dockerfile

docker pull julianbei/data-pipeline-lambdas-source

⁠Example Usage

create two files:

  • index.js
  • Dockerfile
⁠index.js

the index.js must export the run function which gets called as soon as the connection to the broker is established. the first parameter of that function is the queue-reference object which exports two functions:

  • send()
  • sendMore()
var config = {
  AWS_ACCESS_KEY: process.env.AWS_ACCESS_KEY,
  AWS_ACCESS_SECRET: process.env.AWS_ACCESS_SECRET,
  AWS_REGION: process.env.AWS_REGION,
  DESTINATION_TOPIC: process.env.DESTINATION_TOPIC
};
module.exports.config = config;

var message = 'no application provided';
var messages = [
  'no',
  'application',
  'provided'
];

var run = function(queue){
  queue.send(message);
  queue.sendMore(messages);
}

module.exports.run = run;
⁠Dockerfile
FROM julianbei/data-pipeline-lambdas-source

RUN mkdir -p /app/lambda

# Copy the main application.
COPY . ./app/lambda

WORKDIR /app

⁠Options

If you need own dependencies, just create a package.json and install it with your Dockerfile

FROM julianbei/data-pipeline-lambdas-source

RUN mkdir -p /app/lambda

COPY ./package.json /app/package.json
WORKDIR /app
RUN npm install

# Copy the main application.
COPY . ./app/lambda/

If the js module.exports.config in your index.js is not specified, the config gets automatically loaded from your environment.

⁠Docker-Compose Template:

source-lambda:
  build: source-lambda/.
  command: forever -m 5 /app/index.js
  environment:
    - AWS_ACCESS_KEY=
    - AWS_ACCESS_SECRET=
    - AWS_REGION=
    - DESTINATION_TOPIC=

You can optionally reload the app an each change in your app folder. This might be an option for development:

volumes:
  - ./source-lambda:/app/lambda/

Tag summary

Content type

Image

Digest

Size

37.6 MB

Last updated

over 10 years ago

docker pull hitfox/sqs-pipeline-lambdas-node-source