Amazon DynamoDB is a fully managed NoSQL database service
provides fast and predictable performance with seamless scalability.
DynamoDB offers encryption at rest, which eliminates the operational burden and complexity involved in protecting sensitive data.
provides fast and predictable performance with seamless scalability.
DynamoDB offers encryption at rest, which eliminates the operational burden and complexity involved in protecting sensitive data.
Create database tables that can store and retrieve any amount of data, and serve any level of request traffic.
AWS Management Console to monitor resource utilization and performance metrics.
AWS Management Console to monitor resource utilization and performance metrics.
Select DynamoDB from the services menu
Create a simple table to store data
Create a simple Guestbook table
Once you create table it will be available via ARN (Amazon Resource Number)
Need to add permissions to role to access DynamoDB
Use IAM (Identity Access Management) to add policies to existing role
IAM functionality limited but you can add policies to existing roles
Add inline policy
Select DynamoDB as a service
Configure policy for full access
Click on Review Policy
Enter a policy name and create policy
Your role now has permissions to access your DynamoDB tables
Now we can create the dynamoWrite function to put data into our table
dynamo Write
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient({region: 'us-east-1'});
exports.handler = function(event, context, callback) {
var params = {
Item: {
date: Date.now(),
message: "I love your website!"
},
TableName: 'guestbook'
};
docClient.put(params, function(err, data){
if (err){
callback(err, null);
}else{
callback(null, data);
}
});
}
console.log('Starting Function');
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient({region: 'us-east-1'});
exports.handler = function(event, context, callback) {
var params = {
TableName: 'guestbook',
Key: {
"date": 1550953270989
}
};
docClient.get(params, function(err, data){
if (err){
callback(err, null);
}else{
callback(null, data);
}
});
}
No comments:
Post a Comment