如何在Nodejs中配置AWS dynamoDB区域?(How do I configure the AWS dynamoDB region in Nodejs?)

编程入门 行业动态 更新时间:2024-10-24 21:36:25
如何在Nodejs中配置AWS dynamoDB区域?(How do I configure the AWS dynamoDB region in Nodejs?)

我有以下代码来添加一个项目到dynamoDB。 我已将该区域设置为ap-south-1,但该项目正在添加到我们的东1区域。

AWS.config.update({ region: "ap-south-1", endpoint: "dynamodb.ap-south-1.amazonaws.com" }); var addDocumentToTable = function (tablename, item, callback) { var docClient = new AWS.DynamoDB.DocumentClient(); var params = { TableName: tablename, Item: item } docClient.put(params, function (err, data) { retData = { status: true, message: "Successfully inserted", error: null }; if (err) { retData.status = false; retData.message = "Failed to insert into DynamoDB"; retData.error = err; } callback(err, retData); }); }

I have the following code for adding an item to dynamoDB. I have set the region to ap-south-1, but the item is getting added to us-east-1 region.

AWS.config.update({ region: "ap-south-1", endpoint: "dynamodb.ap-south-1.amazonaws.com" }); var addDocumentToTable = function (tablename, item, callback) { var docClient = new AWS.DynamoDB.DocumentClient(); var params = { TableName: tablename, Item: item } docClient.put(params, function (err, data) { retData = { status: true, message: "Successfully inserted", error: null }; if (err) { retData.status = false; retData.message = "Failed to insert into DynamoDB"; retData.error = err; } callback(err, retData); }); }

最满意答案

将细节添加到DocumentClient已经解决了它。

var docClient = new AWS.DynamoDB.DocumentClient({ region: Config.AWS.AWS_REGION, endpoint: Config.AWS.ENDPOINT });

Adding the details to the DocumentClient has solved it.

var docClient = new AWS.DynamoDB.DocumentClient({ region: Config.AWS.AWS_REGION, endpoint: Config.AWS.ENDPOINT });

更多推荐

本文发布于:2023-08-04 15:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1417804.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区域   如何在   Nodejs   dynamoDB   AWS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!