実行ロールには、DynamoDB へのアクセス権がついている必要があります。
出力結果は、CloudWatch で確認が出来ます。
テーブルの一覧
list_tables.js
var AWS = require("aws-sdk");
var dynamodb = new AWS.DynamoDB({region: 'ap-northeast-1'})
var params = { Limit: 100}
exports.handler = async (event) => {
console.log("*** start ***")
try {
var data = await dynamodb.listTables(params).promise()
console.log(data)
} catch (ee) {
console.log(ee)
}
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
}
return response;
}
テーブルの説明
describe_table.js
var AWS = require("aws-sdk");
var dynamodb = new AWS.DynamoDB({region: 'ap-northeast-1'})
var table = "Movies"
var params = {TableName: table}
exports.handler = async (event) => {
console.log("*** start ***")
try {
var data = await dynamodb.describeTable(params).promise()
console.log(data)
} catch (ee) {
console.log(ee)
}
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
}
return response
}