Is there any way to switch between the DynamoDB regions on the fly by using javascript aws-sdk
or dynamoose
npm package?
Suppose, 2 table exists in two different regions Mumbai (ap-south-1) and Frankfurt (eu-central-1). Initial when appliation boots it uses ap-south-1 and then after some business logic, it needs to route the DB instance to eu-central-1.
So, how can I achieve it by using javascript aws-sdk or dynmoose package.
Right now, I am using the below snippet. But it's not working
import dynamoose from 'dynamoose';
dynamoose.AWS.config.logger = console;
dynamoose.AWS.config.update({ region: 'ap-south-1'}); // working here
// some business login
// ...
// ...
// switch DynamoDB region
dynamoose.AWS.config.update({ region: 'eu-central-1'}); // but it's not working. Not even throwing any error.
Can anyone please help? Is there any way to log the AWS Dynamodb region the specific query run on? Like enabling AWS logger, it just outputs
[AWS dynamodb 200 0.042s 0 retries] getItem({ TableName: 'User', Key: { userId: { S: '99999' } } })