From 3325aeb5124e998d3053f162a332b66987c9ee0a Mon Sep 17 00:00:00 2001 From: David Asamonye Date: Fri, 26 Apr 2024 09:27:20 +0100 Subject: [PATCH] setup AWS secrets --- scripts/test.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 scripts/test.js diff --git a/scripts/test.js b/scripts/test.js new file mode 100644 index 0000000..a8c4188 --- /dev/null +++ b/scripts/test.js @@ -0,0 +1,33 @@ +const { + SecretsManagerClient, + GetSecretValueCommand, + } = require("@aws-sdk/client-secrets-manager"); + + async function test() { + + const secret_name = "KEYSTORE"; + + const client = new SecretsManagerClient({ + region: "us-east-1", + }); + + let response; + + try { + response = await client.send( + new GetSecretValueCommand({ + SecretId: secret_name, + VersionStage: "AWSCURRENT", // VersionStage defaults to AWSCURRENT if unspecified + }) + ); + } catch (error) { + // For a list of exceptions thrown, see + // https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html + throw error; + } + + const secret = response.SecretString; + + console.log(secret); + } + test();