如何在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 });更多推荐
发布评论