The following code demonstrates creating a DynamoDB table via the HTTP API signed with Amazon Signature Version 4:
(function() {
var data = "{\"AttributeDefinitions\":[";
data += "{\"AttributeName\": \"OID\"";
data += ",\"AttributeType\": \"N\"}]";
data += ",\"TableName\": \"TestTable\"";
data += ",\"KeySchema\": [";
data += "{\"AttributeName\": \"OID\"";
data += ",\"KeyType\": \"HASH\"}]";
data += ",\"ProvisionedThroughput\":";
data += "{\"ReadCapacityUnits\": 10";
data += ",\"WriteCapacityUnits\": 10}}";
var headers = {
"Content-Type": "application/x-amz-json-1.0",
"X-Amz-Target": "DynamoDB_20120810.CreateTable"
};
net("POST", "https://dynamodb.us-east-1.amazonaws.com/", headers, data, use("aws4"), function(resp) {
response.end(resp.status);
});
}());