I am working on a nodejs based api using aws dynamodb. API was working fine but today i am getting this error:
{
"success": false,
"message": {
"message": "Missing region in config",
"code": "ConfigError",
"time": "2020-08-17T19:17:17.462Z"
}
}
Below is my user api route:
const AWS = require('aws-sdk');
const config = require('config');
const { v4: uuidv4 } = require('uuid');
// Set the region
AWS.config.update({ region: 'us-east-2' });
router.post(`/api/user`, (req, res) => {
console.log('User Add Services Called');
try {
//Constants
AWS.config.update(config.aws_remote_config);
var params = {
TableName: config.aws_table_name,
Item: {
PK: `${uuidv4()}`,
SK: `User`,
name: 'Test'
}
};
//Calling DynamoDB to add the item to the table
docClient.put(params, function (err) {
if (err) {
res.send({
success: false,
message: err
});
} else {
res.send({
success: true,
message: 'User Added'
});
}
});
} catch (error) {
return res.status(500).json({
status: 'error',
message: 'An error occurred trying to process your request'
});
}
});
Some time these error shows too:
- connect ENETUNREACH 169.254.169.254:80
- Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
Can anyone tell why its happening, API was working fine & I also tried regenerating access keys too but the same issue is coming