Skip to content
This repository has been archived by the owner on Oct 9, 2021. It is now read-only.

Commit

Permalink
v2.0.0 Release
Browse files Browse the repository at this point in the history
Major version release to address updates/issues identified in CHANGELOG.
  • Loading branch information
kylesomers committed Jun 19, 2016
1 parent 1dde27e commit 41a5d6b
Show file tree
Hide file tree
Showing 8 changed files with 476 additions and 337 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
=========
CHANGELOG
=========

2.0.0
=====
* Introduces multi-region stack support for workshop to run in any of the 5 existing regions that have API Gateway and Lambda.
* Solves hardcoded attribute dependencies, allowing for multiple stacks to run simultaneously in the same AWS account. Resources are created with stack name prepended to the resource names.
* Removes caching from API Gateway stage to reduce costs for long running stacks.

1.0.0
==========
* All commits prior to release 2.0.0 are considered a part of v1.0.0 release.
* Initial release on Github.
* Provides baseline zombie survivor chat application via CloudFormation stack, Lambda functions, DynamoDB tables, and API Gateway resources.
24 changes: 17 additions & 7 deletions ChatServiceLambdaFunctions/ZombieGetMessages.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
console.log('Loading function');
var aws = require('aws-sdk');
var ddb = new aws.DynamoDB(
{region: "us-west-2",
params: {TableName: "messages"}});

var ddb;

var theContext;

function dynamoCallback(err, response) {
if (err) {
if (err) {
console.log('error' + err, err.stack); // an error occurred
theContext.fail(err);
}

else {
console.log('result: ' + JSON.stringify(response)) // successful response
console.log('result: ' + JSON.stringify(response)) // successful response
theContext.succeed(response);
}
}

function init(context) {
if(!ddb) {
var stackName = context.functionName.split('-z0mb1es-')[0];
var stackRegion = context.functionName.split('-GetMessagesFromDynamoDB-')[1];
ddb = new aws.DynamoDB({
region: stackRegion,
params: { TableName: stackName + "-messages" }
});
}
}

exports.handler = function(event, context) {
init(context);
theContext = context;
var params = {
"KeyConditions": {
Expand Down
28 changes: 19 additions & 9 deletions ChatServiceLambdaFunctions/ZombiePostMessage.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Processes incoming messages for Zombie chat service
var aws = require('aws-sdk');
var ddb = new aws.DynamoDB(
{region: "us-west-2",
params: {TableName: "messages"}}
);
var ddb;
var querystring = require('querystring');

var theContext;
Expand All @@ -16,20 +13,21 @@ var channel = 'default';


exports.handler = function(event, context) {
init(context);
theContext = context;

if(event.message == null || event.message == 'null' || event.name == null || event.name == 'null') {
return context.fail("Message and Name cannot be null");
return context.fail("Message and Name cannot be null");
} else {
message = event.message;
from = event.name;
}

if (event.timestamp == null || event.timestamp == 'null') {
event.timestamp = "" + new Date().getTime();
timestamp = event.timestamp;
}

/**
* For Debubugging input params to the lambda function
console.log('Message: ' + message);
Expand All @@ -45,10 +43,22 @@ exports.handler = function(event, context) {
"name":{"S":from}
}
};

dynamoPut(DDBparams);
};

function init(context) {
if(!ddb) {
console.log("Initializing DynamoDB client.");
var stackName = context.functionName.split('-z0mb1es-')[0];
var stackRegion = context.functionName.split('-WriteMessagesToDynamoDB-')[1];
ddb = new aws.DynamoDB({
region: stackRegion,
params: { TableName: stackName + "-messages" }
});
}
}

function dynamoPut(params){
console.log("Putting item into DynamoDB");
ddb.putItem(params, dynamoCallback);
Expand Down
Loading

0 comments on commit 41a5d6b

Please sign in to comment.