This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Using Document Client | |
var params = { | |
Item: { | |
hashkey: 'key', | |
boolAttr: true, | |
listAttr: [1, 'baz', true] | |
mapAttr: { | |
foo: 'bar' | |
} | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Using low-level API Client | |
var params = { | |
Item: { | |
hashkey: { "S" : "key"}, | |
boolAttr: { "B" : "true" }, | |
listAttr: { "L" : [{ "N" : 1}, { "S":'baz'}, { B: "true" }]} | |
mapAttr: { | |
M : { | |
"foo": { "S" : "bar"} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
“userId” : { | |
“S” : “$MY_USER_ID” | |
}, | |
“accountBalance” : { | |
“N” : “0” | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var presignIOTMQTTConnection = function(endpoint, credentials) { | |
//Turn off param validation because of the hackery coming up | |
var service = new AWS.IotData({endpoint : endpoint, credentials : credentials, paramValidation: false}); | |
//MQTT broker uses a different servicename in the sigv4 algo | |
service.api.signingName = "iotdevicegateway"; | |
//1. Create a request object for another, sorta similar request | |
//2. Save off our session token and delete it from the credentials(so it doesn't get signed) | |
//3. Register to an event in the state machine to adjust the path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* utilities to do sigv4 | |
* @class SigV4Utils | |
*/ | |
function SigV4Utils() {} | |
SigV4Utils.getSignatureKey = function (key, date, region, service) { | |
var kDate = AWS.util.crypto.hmac('AWS4' + key, date, 'buffer'); | |
var kRegion = AWS.util.crypto.hmac(kDate, region, 'buffer'); | |
var kService = AWS.util.crypto.hmac(kRegion, service, 'buffer'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Turn off param validation because of the hackery coming up | |
var service = new AWS.IotData({endpoint : "data.iot.us-east-1.amazonaws.com", credentials : credentials, paramValidation : false}); | |
//MQTT broker uses a different servicename in the sigv4 algo | |
service.api.signingName = "iotdevicegateway"; | |
//Connecting to MQTT isn't actually a published operation. | |
//soooo Let's copy another GET request for some hackery.. | |
var connect = $.extend(true, {}, service.api.operations.getThingShadow); | |
//..change the path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Resources: | |
CrashingLambda: | |
Type: AWS::Lambda::Function | |
Properties: | |
Code: | |
ZipFile: > | |
exports.handler = function(event, context) { | |
FunctionDoesntExist(); | |
}; | |
Handler: index.handler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"dynamodb:GetItem", | |
"dynamodb:BatchGetItem", | |
"dynamodb:Query", | |
"dynamodb:PutItem", |
NewerOlder