diff --git a/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts b/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts index 5d1a651f00..32b55777e4 100644 --- a/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts +++ b/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts @@ -81,15 +81,17 @@ class DynamoDBPersistenceLayer extends BasePersistenceLayer { this.staticPkValue = config.staticPkValue ?? `idempotency#${this.idempotencyKeyPrefix}`; - this.client = new DynamoDBClient(config?.clientConfig ?? {}); - if (config?.awsSdkV3Client) { - if (isSdkClient(config.awsSdkV3Client)) { - this.client = config.awsSdkV3Client; - } else { + if (config.awsSdkV3Client) { + if (!isSdkClient(config.awsSdkV3Client)) { console.warn( 'awsSdkV3Client is not an AWS SDK v3 client, using default client' ); + this.client = new DynamoDBClient(config.clientConfig ?? {}); + } else { + this.client = config.awsSdkV3Client; } + } else { + this.client = new DynamoDBClient(config.clientConfig ?? {}); } addUserAgentMiddleware(this.client, 'idempotency'); }