I am upgrading nodejs from older version to node 16 as AWS-SDK has announced end of support for Node.js 14.x. i am using dynamoose package for dynamodb connection and other operations. now with nodejs 16, getting region is missing error even though region is set at all possible ways
Error: Region is missing at default (/home/myproject/node_modules/@aws-sdk/config-resolver/dist-cjs/regionConfig/config.js:10:15)
tried all these methods to set region
1. const ddb = new dynamoose.aws.ddb.DynamoDB({
region: config.aws.region,
accessKeyId: config.aws.accessKeyId,
secretAccessKey: config.aws.secretAccessKey,
});
// Set DynamoDB instance to the Dynamoose DDB instance
dynamoose.aws.ddb.set(ddb);
2. var AWS = require('aws-sdk');
AWS.config.loadFromPath('./aws.json');
AWS.config.getCredentials(function(err) {
if (err) console.log(err.stack);
// credentials not loaded
else {
console.log("Access key:", AWS.config.credentials.accessKeyId);
console.log("secretAccessKey:", AWS.config.credentials.secretAccessKey);
console.log("credentials.region:", AWS.config.credentials.region);
console.log("region: ", AWS.config.region);
}
});
Able to get AWS.config.region in logs :
Access key: XXXXX
secretAccessKey: XXXXXXXXXXXXXXXXXX
credentials.region: undefined
region: ap-southeast-1
aws version: 2.1231.0
3. AWS.config.update({region:'ap-southeast-1'});
4. set region if not set (as not set by the SDK by default)
if (!AWS.config.region) {
AWS.config.update({
region: 'eu-west-1'
});
}
please help me to resolve this issue
- node -v : v16.17.1
- npm -v : 8.15.0
- aws version: 2.1231.0
- dynamoose : 3.1.0