Skip to content

Instantly share code, notes, and snippets.

@azcoov
Last active August 29, 2015 14:20
Show Gist options
  • Save azcoov/c2980ef5c6da9a053435 to your computer and use it in GitHub Desktop.
Save azcoov/c2980ef5c6da9a053435 to your computer and use it in GitHub Desktop.
var QUEUE_URL = 'https://sqs.us-east-1.amazonaws.com/{AWS_ACCUOUNT_}/matsuoy-lambda';
var AWS = require('aws-sdk');
var sqs = new AWS.SQS({region : 'us-east-1'});
exports.handler = function(event, context) {
var params = {
MessageBody: JSON.stringify(event),
QueueUrl: QUEUE_URL
};
sqs.sendMessage(params, function(err,data){
if(err) {
console.log('error:',"Fail Send Message" + err);
context.done('error', "ERROR Put SQS"); // ERROR with message
}else{
console.log('data:',data.MessageId);
context.done(null,''); // SUCCESS
}
});
}
#!/bin/sh
FUNCTION_JS=sendsqs.js
FUNCTION_FILE=sendsqs.zip
FUNCTION_NAME=sendsqs
REGION=us-east-1
EXEC_ROLE='arn:aws:iam::{AWS_ACCUOUNT_}:role/lambda_exec_role'
zip $FUNCTION_FILE $FUNCTION_JS
aws lambda upload-function \
--region $REGION \
--function-name $FUNCTION_NAME \
--function-zip $FUNCTION_FILE \
--role $EXEC_ROLE \
--mode event \
--handler $FUNCTION_NAME.handler \
--runtime nodejs \
--description "test" \
--timeout 60 \
--memory-size 128 \
--debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment