1- // start-custom-credentials
2- const { MongoClient } = require ( 'mongodb' ) ;
3- const { fromNodeProviderChain } = require ( '@aws-sdk/credential-providers' ) ;
1+ {
2+ // start-custom-credentials
3+ const { MongoClient } = require ( 'mongodb' ) ;
4+ const { fromNodeProviderChain } = require ( '@aws-sdk/credential-providers' ) ;
45
5- const client = new MongoClient ( '<cluster_url>?authMechanism=MONGODB-AWS' , {
6- authMechanismProperties : {
7- AWS_CREDENTIAL_PROVIDER : fromNodeProviderChain ( )
8- }
9- } ) ;
10- // end-custom-credentials
6+ const client = new MongoClient ( '<cluster_url>?authMechanism=MONGODB-AWS' , {
7+ authMechanismProperties : {
8+ AWS_CREDENTIAL_PROVIDER : fromNodeProviderChain ( )
9+ }
10+ } ) ;
11+ // end-custom-credentials
12+ }
1113
14+ {
1215// start-custom-credentials-function
13- const { MongoClient } = require ( 'mongodb' ) ;
16+ const { MongoClient } = require ( 'mongodb' ) ;
1417
15- const client = new MongoClient ( '<cluster_url>?authMechanism=MONGODB-AWS' , {
16- authMechanismProperties : {
17- AWS_CREDENTIAL_PROVIDER : async ( ) => {
18- return {
19- accessKeyId : process . env . ACCESS_KEY_ID ,
20- secretAccessKey : process . env . SECRET_ACCESS_KEY
18+ const client = new MongoClient ( '<cluster_url>?authMechanism=MONGODB-AWS' , {
19+ authMechanismProperties : {
20+ AWS_CREDENTIAL_PROVIDER : async ( ) => {
21+ return {
22+ accessKeyId : process . env . ACCESS_KEY_ID ,
23+ secretAccessKey : process . env . SECRET_ACCESS_KEY
24+ }
2125 }
2226 }
23- }
24- } ) ;
25- // end-custom-credentials-function
27+ } ) ;
28+ // end-custom-credentials-function
29+ }
0 commit comments