Permalink
Browse files

Fixed up lambda functions

  • Loading branch information...
mcasperson committed Jan 28, 2018
1 parent 1864f73 commit 96b9abb541153ff25a47a5a0f05e2c36a01aa28b
Showing with 17 additions and 16 deletions.
  1. +10 −9 lambdas/InvokeLambda.js
  2. +7 −7 lambdas/SaveDynamoDB.js
View
@@ -1,37 +1,38 @@
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'us-east1'});
AWS.config.update({region: 'us-east-1'});
var lambda = new AWS.Lambda();
exports.handler = function(event, context) {
exports.handler = function(event, context, callback) {
var iridiumParams = {
FunctionName: 'Iridium',
InvocationType: 'RequestResponse',
LogType: 'Tail',
Payload: event.iridiumSettings
Payload: JSON.stringify(event.iridiumSettings)
};
lambda.invoke(iridiumParams, function(err, data) {
if (err) {
context.fail(err);
callback(err);
} else {
var dynamoDBParams = {
FunctionName: 'IridiumResults',
InvocationType: 'RequestResponse',
LogType: 'Tail',
Payload: {
Payload: JSON.stringify({
table: "IridiumResults",
testName: event.testName,
result: data.Payload
}
})
};
lambda.invoke(dynamoDBParams, function(err, data) {
if (err) {
context.fail(err);
callback(err);
} else {
context.success("Ran Iridium and saved results");
callback(null, "Ran Iridium and saved results");
}
};
});
}
})
};
View
@@ -1,26 +1,26 @@
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'us-east1'});
AWS.config.update({region: 'us-east-1'});
// Create the DynamoDB service object
ddb = new AWS.DynamoDB({apiVersion: '2012-10-08'});
const ddb = new AWS.DynamoDB({apiVersion: '2012-10-08'});
exports.handler = function(event, context) {
exports.handler = function(event, context, callback) {
var params = {
TableName: event.table,
Item: {
'TestName': event.testName,
'Result': event.result
'TestName': {S: event.testName},
'Result': {S: event.result}
}
};
// Call DynamoDB to add the item to the table
ddb.putItem(params, function (err, data) {
if (err) {
console.log("Error", err);
callback(err);
} else {
console.log("Success", data);
callback(null, "Success");
}
});
};

0 comments on commit 96b9abb

Please sign in to comment.