Skip to content

Instantly share code, notes, and snippets.

View jinman's full-sized avatar

Jinesh Varia jinman

View GitHub Profile
@jinman
jinman / gist:1dfae868bb18e950b0c031c80158e942
Created September 15, 2016 23:44
LambdaToNannyCheckinCheckout
/**
* This is a sample Lambda function that records nanny check in/out activities
* in DynamoDB and sends SMS messages to the phone number on file.
*
* This function creates a DynamoDB table 'button_nanny_checkin' the first time
* it runs. The table uses button's DSN as hash key and timestamp as range key.
* Each entry has an activity message.
*
* If phone number is set, an SMS message about this check in/out activity will
* be sent.
// create an IAM Lambda role with access to dynamodb
// Launch Lambda in the same region as your dynamodb region
// (here: us-east-1)
// dynamodb table with hash key = dsn, uniqueid (hashkey for GSI), data (String/Blob)
console.log('Loading function');
const AWS = require('aws-sdk');
const dynamodb = new AWS.DynamoDB();
exports.handler = function(event, context) {
@jinman
jinman / LambdaToDynamoDBPut
Last active September 30, 2016 20:54
LambdaToDynamoDBPut
// create an IAM Lambda role with access to dynamodb
// Launch Lambda in the same region as your dynamodb region
// (here: us-east-1)
// dynamodb table with hash key = dsn
console.log('Loading function');
const AWS = require('aws-sdk');
const dynamodb = new AWS.DynamoDB();
exports.handler = function(event, context) {