Last active
March 18, 2026 16:31
-
-
Save rxgx/7e1b24de5936ff1b2b815a3d9cc3897a to your computer and use it in GitHub Desktop.
Revisions
-
rxgx revised this gist
May 4, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,7 @@ function getAwsSecret(secretName) { } // Create a async function to use the Promise // Top level await is a proposal async function getAwsSecretAsync (secretName) { var error; var response = await getAwsSecret(secretName).catch(err => (error = err)); -
rxgx created this gist
May 4, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ const AWS = require('aws-sdk'); const client = new AWS.SecretsManager({}); // Call the AWS API and return a Promise function getAwsSecret(secretName) { return client.getSecretValue({ SecretId: secretName }).promise(); } // Create a async function to use the Promise async function getAwsSecretAsync (secretName) { var error; var response = await getAwsSecret(secretName).catch(err => (error = err)); return [error, response]; } // Call the async function and return NodeJS callback style module.exports = function asyncExample () { var [error, secret] = getAwsSecretAsync('dev/MySecret/MyService'); if (error) { // Trigger an error and halt console.error(error); return; } // Use the result console.debug(secret); }