Use the AWS Javscript SDK to queue a new item in a SQS Standard Queue. This requires a reference to the Javascript SDK (https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html). This also uses AWS Congnito to allow an unauth user to access AWS resources.
AWS.config.region = "us-east-1";
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: "us-east-1:SOMEGUID",
});
var aws_sqs = new AWS.SQS();
//create sqs item
//this is a custom json object to represent the data we want to pass in
var sqs_message_obj =
{
type: "customer-support",
name: "My Name",
email: "email@example.com",
subject: "help",
body: "how do I create a support ticket?",
};
//turn sqs message into a string
var sqs_message = JSON.stringify(sqs_message_obj);
//object to use in sqs function
var params = {
MessageBody: sqs_message,
QueueUrl: "https://sqs.us-east-1.amazonaws.com/my_id/something-something"
};
aws_sqs.sendMessage(params, function (err, data)
{
if (err)
{
// an error occurred
}
else
{
// successful response
}
});