AWS SQS: Queue Item from Javacript SDK

10/3/2019 6:13:13 PM

Use the AWS Javscript SDK to queue a new item in a SQS Standard Queue. This requires a reference to the Javascript SDK ( 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: "",
	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: ""            

aws_sqs.sendMessage(params, function (err, data)
	if (err)
		// an error occurred		
		// successful response