Amazon DynamoDB Load Shared Config in NodeJS
AmazonDynamoDBLoadSharedConfiginNodeJS
BeforeloadtheAWS-SDK,setthesystemtoloadtheConfigfileaswellastheCREDETIALfile
>ls-l~/.aws/
total16
-rw-r--r--1hluostaff29Apr1215:28config
-rw-------1hluostaff238May1614:06credentials
process.env.AWS_SDK_LOAD_CONFIG=true;
constAWS=require("aws-sdk");
varcredentials=newAWS.SharedIniFileCredentials();
AWS.config.credentials=credentials;
constdynamoDb=newAWS.DynamoDB.DocumentClient();
BeforeconstructtheDBdocumentclient,inittheconfigurationtoloadthesharedInFile
References:
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-environment.html
https://stackoverflow.com/questions/44433527/how-to-load-config-from-aws-config