Exmaple handler given a DynamoDB table your-table with hash key uuid
.
const AWS = require('aws-sdk');
AWS.config.update({region: 'eu-west-1'});
const dynamo = new AWS.DynamoDB.DocumentClient({apiVersion: '2012-08-10'});
exports.handler = async (event) => {
//console.log('Received event:::', JSON.stringify(event));
const params = {
TableName : 'your-table',
Item: {
'uuid': '4711',
'lala': event.queryStringParameters.lala
}
};
let result;
try {
result = await dynamo.put(params).promise();
} catch(error) {
console.log('error: ' + error);
}
console.log('result: ' + JSON.stringify(result));
return {};
};
GET
params = {
TableName: 'your-table',
Key: {
'uuid': '4893458348957'
}
}