After a long time of reading docs and debugging, I have been stuck on this error for a while and cannot seem to find any fix: CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
import aws from "aws-sdk";
const ses = new aws.SES({ region: "us-east-1" });
const buildEmailParams = (receiverEmail, subject, htmlBody) => {
return {
Destination: {
ToAddresses: [receiverEmail],
BccAddresses: [],
CcAddresses: []
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: htmlBody
},
},
Subject: {
Charset: "UTF-8",
Data: subject
}
},
ReturnPath: "support@scilynk.com",
Source: "support@scilynk.com",
};
};
const sendSESEmail = async (data) => {
const { receiverEmail, subject, htmlBody } = data;
const params = buildEmailParams(receiverEmail, subject, htmlBody);
try {
await ses.sendEmail(params).promise(); // ERROR IS HERE
console.log("Email sent successfully");
return true;
} catch (err) {
console.log(err);
throw err;
}
};
export { sendSESEmail };
I have added my .env variables, they are configured correctly, and I have restarted the server several times. I tried importing { config } from the aws-sdk module and add this code:
config.update({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
});
which also proved to yield in the same issue. All of my environment variables are set up correctly, my access key is correct, but there seems to be no way around this error. Is my entire setup wrong? I must be overlooking something.
I have added my .env variables, they are configured correctly, and I have restarted the server several times. I tried importing { config } from the aws-sdk module and add this code:
config.update({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
});