diff --git a/aws/cognito/lambda/cognito_email_sender/cognito_email_sender.ts b/aws/cognito/lambda/cognito_email_sender/cognito_email_sender.ts index 663db3355..0195c41a9 100644 --- a/aws/cognito/lambda/cognito_email_sender/cognito_email_sender.ts +++ b/aws/cognito/lambda/cognito_email_sender/cognito_email_sender.ts @@ -9,8 +9,7 @@ const TEMPLATE_ID = process.env.TEMPLATE_ID; if (!KEY_ARN || !KEY_ALIAS || !TEMPLATE_ID) { throw new Error( - `Missing Environment Variables: ${KEY_ARN ? "" : "Key ARN"} ${KEY_ALIAS ? "" : "Key Alias"} ${ - TEMPLATE_ID ? "" : "Template ID" + `Missing Environment Variables: ${KEY_ARN ? "" : "Key ARN"} ${KEY_ALIAS ? "" : "Key Alias"} ${TEMPLATE_ID ? "" : "Template ID" }` ); } @@ -19,7 +18,7 @@ const client = new SecretsManagerClient(); const command = new GetSecretValueCommand({ SecretId: process.env.NOTIFY_API_KEY }); console.log("Retrieving Notify API Key from Secrets Manager"); const notifyApiKey = await client.send(command); -const notifyClient = new NotifyClient("https://api.notification.canada.ca", notifyApiKey); +const notifyClient = new NotifyClient("https://api.notification.canada.ca", notifyApiKey.SecretString); export const handler: Handler = async (event) => { // setup the encryptionSDK's key ring diff --git a/aws/lambdas/code/nagware/lib/emailNotification.ts b/aws/lambdas/code/nagware/lib/emailNotification.ts index 7ef8a319e..27951665e 100644 --- a/aws/lambdas/code/nagware/lib/emailNotification.ts +++ b/aws/lambdas/code/nagware/lib/emailNotification.ts @@ -6,7 +6,7 @@ const client = new SecretsManagerClient(); const command = new GetSecretValueCommand({ SecretId: process.env.NOTIFY_API_KEY }); console.log("Retrieving Notify API Key from Secrets Manager"); const notifyApiKey = await client.send(command); -const notifyClient = new NotifyClient("https://api.notification.canada.ca", notifyApiKey); +const notifyClient = new NotifyClient("https://api.notification.canada.ca", notifyApiKey.SecretString); export async function notifyFormOwner( formID: string, diff --git a/aws/lambdas/code/reliability/lib/notifyProcessing.ts b/aws/lambdas/code/reliability/lib/notifyProcessing.ts index 81fabe165..3f83e4ac0 100644 --- a/aws/lambdas/code/reliability/lib/notifyProcessing.ts +++ b/aws/lambdas/code/reliability/lib/notifyProcessing.ts @@ -3,7 +3,6 @@ import convertMessage from "./markdown.js"; import { extractFileInputResponses, notifyProcessed } from "./dataLayer.js"; import { retrieveFilesFromReliabilityStorage } from "./s3FileInput.js"; import { FormSubmission } from "./types.js"; -import { ClientRequest } from "http"; import { AxiosError } from "axios"; import { SecretsManagerClient, GetSecretValueCommand } from "@aws-sdk/client-secrets-manager"; @@ -11,17 +10,7 @@ const client = new SecretsManagerClient(); const command = new GetSecretValueCommand({ SecretId: process.env.NOTIFY_API_KEY }); console.log("Retrieving Notify API Key from Secrets Manager"); const notifyApiKey = await client.send(command); -const notifyClient = new NotifyClient("https://api.notification.canada.ca", notifyApiKey); - -type NetworkError = { - request?: ClientRequest; - response?: { - data: { - errors?: unknown[]; - }; - status: string; - }; -}; +const notifyClient = new NotifyClient("https://api.notification.canada.ca", notifyApiKey.SecretString); export default async ( submissionID: string, @@ -61,8 +50,8 @@ export default async ( ? formSubmission.deliveryOption.emailSubjectFr : formSubmission.form.titleFr : formSubmission.deliveryOption.emailSubjectEn - ? formSubmission.deliveryOption.emailSubjectEn - : formSubmission.form.titleEn; + ? formSubmission.deliveryOption.emailSubjectEn + : formSubmission.form.titleEn; await notifyClient.sendEmail(templateID, formSubmission.deliveryOption.emailAddress, { personalisation: {