javascriptnode.jstypescriptamazon-web-servicesamazon-qldb

AWS QLDB [ERROR] [Node.js QLDB Sample Code] Unable to create the ledger: ConfigError: Missing region in config


AWS QLDB CreateLedger.js throwing error.

~repo/amazon-qldb-dmv-sample-nodejs$ node dist/CreateLedger.js 
[LOG][Node.js QLDB Sample Code] Creating a ledger named: vehicle-registration...
[AWS qldb undefined 0.005s 0 retries] createLedger({ Name: 'vehicle-registration', PermissionsMode: 'ALLOW_ALL' })
[ERROR][Node.js QLDB Sample Code] Unable to create the ledger: ConfigError: Missing region in config.

How to update region in nodejs Typescript code in CreateLedger.js

https://docs.aws.amazon.com/qldb/latest/developerguide/getting-started.nodejs.step-1.html

I want to add region in CreateLeger.TS file

import { QLDB } from "aws-sdk";

import {
    CreateLedgerRequest,
    CreateLedgerResponse,
    DescribeLedgerRequest,
    DescribeLedgerResponse,
 } from "aws-sdk/clients/qldb";

import { LEDGER_NAME } from "./qldb/Constants";
import { error, log } from "./qldb/LogUtil";
import { sleep } from "./qldb/Util";

const LEDGER_CREATION_POLL_PERIOD_MS = 10000; const ACTIVE_STATE = 
"ACTIVE";

export async function createLedger(ledgerName: string, qldbClient: 
QLDB): Promise<CreateLedgerResponse> {
log(`Creating a ledger named: ${ledgerName}...`);
const request: CreateLedgerRequest = {
    Name: ledgerName,
    PermissionsMode: "ALLOW_ALL"
}
const result: CreateLedgerResponse = await 
qldbClient.createLedger(request).promise();`enter code here`
log(`Success. Ledger state: ${result.State}.`);
return result; }

In which section I can add the region. So generated 
dist/createLedger.js file have the changes

Solution

  • After some try I got the answer. you can update config in this file ~src/qldb/logutil.ts

       import { config } from "aws-sdk";
    
       config.logger = console;
       config.update({region: 'us-east-1'});