0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Lambda から DynamoDB にアクセス (Node.js)

Last updated at Posted at 2020-03-05

実行ロールには、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
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?