I have a Next.js application that is deployed to Zeit. I want to have an access to some of AWS services: SNS to send text messages and DynamoDB to store some data.
There is aws-sdk available for JavaScript so it is pretty easy to utilize any service from AWS
Example function to send text messages
import SNS from 'aws-sdk/clients/sns';
export function sendTextMessage(message, phone) {
return new Promise((resolve, reject) => {
const snsParams = {
Message: message,
PhoneNumber: phone
};
const snsClient = new SNS({ region: 'us-east-1' });
snsClient.publish(snsParams, (error, data) => {
if (error) {
reject(error);
} else {
resolve(data);
}
});
});
}
The question is where/how can I safely store AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY on Zeit hosting? So it is not exposed to end users.
Any help is appreciated! Thanks