Closed cbjjensen closed 2 years ago
since this is just a wrapper of dynamoose, please make feature request over there.
@hardyscc this is not so much a feature request as much as it is a question about how to configure nestjs-dynamoose to use dax. dynamoose does support dax configuration, but I am unsure how to pass in configuration into nestjs-dynamoose for it to use dax.
Note the parameter here found in this pr: https://github.com/dynamoose/dynamoose/pull/330/files#diff-2eb2746547ba4e5403ca09626c2b38f2d201f4e3a0cb5ab97567030c48366acd
As well as this : https://v1.dynamoosejs.com/api/config/#dynamoosesetdocumentclientdocumentclient
sample usage of dax: https://github.com/dynamoose/dynamoose/issues/764#issuecomment-759924968
const AmazonDaxClient = require('amazon-dax-client');
const dax = new AmazonDaxClient({endpoints: [endpoint], region: region});
const dynamoose = require("dynamoose");
dynamoose.aws.ddb.set(dax);
@cbjjensen
could you help to try if this work or not?
import AmazonDaxClient from 'amazon-dax-client';
...
DynamooseModule.forRoot({
ddb: new AmazonDaxClient({endpoints: [endpoint], region: region}) as any,
}),
@Module({
imports: [
ConfigModule.forRoot({ envFilePath: '.env' }),
DynamooseModule.forRoot({
logger: false,
// aws: {
// region: process.env.AWS_REGION,
// accessKeyId: process.env.AWS_ACCESS_KEY,
// secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
// },
ddb: new AmazonDaxClient({
endpoints: [
'daxs://dax-franchise-new.rvgqtq.dax-clusters.ap-northeast-1.amazonaws.com',
],
region: process.env.AWS_REGION,
}) as any,
table: {
// create: true,
// waitForActive: false,
initialize: false,
// update: false,
// tableClass: TableClass.standard,
// throughput: 'ON_DEMAND',
// prefix:
// process.env.NODE_ENV !== 'dev' ? `${process.env.NODE_ENV}-` : '',
},
}),
],
providers: [transactionBase],
exports: [transactionBase],
})
export class DynamodbModule {}
I config like this, but if key initialize = false it'll throw error "Table category has not been initialized." if key initialize = true, i can't start source because DAX throw error
node_modules/amazon-dax-client/src/AmazonDaxClient.js:158 throw new DaxClientError('createTable is not support for DAX. Use AWS.DynamoDB instead.', DaxErrorCode.Validation, false);
I really stuck in here. please help
@cbjjensen did you try table: { create: false }
?
@hardyscc Yes i did. when i call any server, they threw error because it does not find table i can not set table: { create: true } because DAX not support create table in dynamodb
please refer to https://github.com/hardyscc/aws-nestjs-starter how to create table using serverless
see https://github.com/hardyscc/aws-nestjs-starter/blob/master/resource/dynamodb.yml
and here is how to generate this file https://github.com/hardyscc/aws-nestjs-starter/blob/master/genres.ts
@hardyscc I'm using cdk and create table in aws, and i sure that the table already exist in dynamodb but seem dax can not found the table. I confuse and unknown the reason why, because there is non error has been thrown
@cbjjensen I think you should get help from dynamoose, since this is just a wrapper of it.
@hardyscc Sadly, i asked Charlie Fish. And he confirmed dax not work in dynamoose V3
How can we configure this to use DAX Client ? https://aws.amazon.com/dynamodb/dax/
https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dax/index.html