Skip to content

Commit

Permalink
fix(Workbench): ssm client generation canary
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeaturner committed Mar 17, 2024
1 parent 5f8296c commit 13ab74a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/util/librariesclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export async function generateLibrariesSSMClient(): Promise<LibrariesSSMClient |
process.env.AWS_SSM_LIB_TOKEN_PAIR_PATH || "/libkeys/production";
const apiUsername = process.env.LIBRARIES_API_USERNAME || "LibreBot";

console.log('Generating Libraries SSM Client');
console.log('libTokenPairPath: ' + libTokenPairPath);
console.log('apiUsername: ' + apiUsername);

const ssm = new SSMClient({
credentials: {
accessKeyId: process.env.AWS_SSM_ACCESS_KEY_ID || "unknown",
Expand All @@ -26,6 +30,9 @@ export async function generateLibrariesSSMClient(): Promise<LibrariesSSMClient |
region: process.env.AWS_SSM_REGION || "unknown",
});

console.log('SSM Client generated with credentials:')
console.log(ssm.config.credentials)

return {
apiUsername,
libTokenPairPath,
Expand Down Expand Up @@ -73,6 +80,9 @@ export async function getLibraryTokenPair(
})
);

console.log('SSM GetParametersByPathCommand response: ')
console.log(pairResponse.$metadata)

if (pairResponse.$metadata.httpStatusCode !== 200) {
console.error(pairResponse.$metadata);
throw new Error("Error retrieving library token pair.");
Expand All @@ -93,6 +103,8 @@ export async function getLibraryTokenPair(
throw new Error("Error retrieving library token pair.");
}

console.log('Library token pair retrieved')

return {
key: libKey.Value,
secret: libSec.Value,
Expand All @@ -116,10 +128,12 @@ export async function generateAPIRequestHeaders(
? libClient
: await generateLibrariesSSMClient(); // generate a new client if one is not provided
if (!libsClient) {
console.error("Failed attempt to generate libraries client.")
throw new Error("Error generating libraries client.");
}
const keyPair = await getLibraryTokenPair(lib, libsClient);
if (!keyPair) {
console.log("Failed attempt to generate library token pair.")
throw new Error("Error generating library token pair.");
}

Expand Down

0 comments on commit 13ab74a

Please sign in to comment.