Setting up Amazon SQS:

Create an AWS account

One you login change the region on top right to required region ( I was using Ireland [eu-west-1])


Create an IAM user

  • Sign in to IAM Console: https://console.aws.amazon.com/iam/home#/homeby choosing Root user and entering your AWS account email address. On the next page, enter your password.
  • In the navigation pane, choose Usersand then choose Add user.
  • For User name, enter Administrator.
  • Select the check box next to AWS Management Console access. Then select Custom password, and then enter your new password in the text box.
  • (Optional) By default, AWS requires the new user to create a new password when first signing in. You can clear the check box next to User must create a new password at next sign-into allow the new user to reset their password after they sign in.
  • Choose Next: Permissions.
  • Under Set permissions, choose Add user to group.
  • Choose Create group.
  • In the Create groupdialog box, for Group name enter Administrators.
  • Choose Filter policies, and then select AWS managed -job functionto filter the table contents.
  • In the policy list, select the check box for AdministratorAccess. Then choose Create group.
  • Back in the list of groups, select the check box for your new group. Choose Refreshif necessary to see the group in the list.
  • Choose Next: Tags.
  • (Optional) Add metadata to the user by attaching tags as key-value pairs.
  • Choose Next: Reviewto see the list of group memberships to be added to the new user. When you are ready to proceed, choose Create user.

Get your access key ID and secret access key

To use Amazon SQS actions (for example, using Java or through the AWS Command Line Interface), you need an access key ID and a secret access key.

  • Sign in to the AWS Management Console and open the IAM console
  • In the navigation pane, choose Users.
  • Choose the name of the user whose access keys you want to create, and then choose the Security credentials
  • In the Access keyssection, choose Create access key.
  • To view the new access key pair, choose Show. You will not have access to the secret access key again after this dialog box closes. Your credentials will look something like this:

Access key ID: AKIAIOSFODNN7EXAMPLE

Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

  • To download the key pair, choose Download .csv file.After you download the .csvfile, choose Close

Getting started with Amazon SQS:

Create a queue:

  • Open the Amazon SQS console at https://console.aws.amazon.com/sqs/
  • Choose Create queue.
  • On the Create queue page, ensure that you set the correct region.
  • The Standard queue type is selected by default. Choose FIFO. You can't change the queue type after you create a queue.
  • Enter a Name for your queue. The name of a FIFO queue must end with the .fifo
  • To create your queue with the default parameters, scroll to the bottom and choose Create Queue. Amazon SQS creates the queue and displays the queue's Details page

Send a message:

After you create your queue, you can send a message to it.

  • From the left navigation pane, choose Queues. From the queue list, select the queue that you created.
  • From Actions, choose Send and receive messages. The console displays the Send and receive messages page
  • Enter text in the Message body
  • Enter a Message group id for the queue.
  • (Optional) Enter a Message deduplication id. If you enable content-based deduplication, the message deduplication ID is not required.
  • Choose Send message.
  • Your message is sent and the console displays a success message. Choose View details to display information about the sent message.

Receive and delete your message

  • From the Queues page, select a queue.
  • From Queue Actions, select Send and receive messages. The console displays the Send and receive messages
  • Choose Poll for messages. Amazon SQS begins to poll servers to find messages in the queue. The progress bar on the right side of the Receive messages section displays the polling duration.
  • To delete messages, select the messages that you want to delete and then choose Delete.
  • In the Delete Messages dialog box, choose Delete.

Delete your queue:

  • From the queue list, select the queue that you have created.
  • From the Queuespage, select the queue to delete.
  • Choose Delete queue.

The console displays the Delete queuedialog box.

  • In the Delete queuedialog box, confirm the deletion by entering delete.
  • Choose Delete.

Send and Receive messages using cli:

  • Install node js.
  • Install aws-cli in ubuntu:  sudo apt-get install awscli
  • Check whether aws cli is working: aws --version
  • Configure AWS credentials: aws configureand fill the required details.
  • Create send and receive js files and run the code in node js. You can obtain the data.

Example code reference to send, receive and list queues:

https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javascript/example_code/sqs


Integrate SQS with AWS Lambda:

Send Message from SQS and Receive from Lambda Console

  • Open AWS lambda console https://eu-west-1.console.aws.amazon.com/lambda/home?region=eu-west-1#/functions
  • ChooseCreate a function and choose from scratch option
  • For Function name, enter my-function.
  • Choose the runtime language to run the function.
  • In Permissions choose the execution rule
  • Choose Create function.
  • Once the function is created open the function that is created a Designershows an overview of your function and its upstream and downstream resources. You can use it to configure triggers, layers, and destinations.
  • In triggers add the trigger and choose SQS as trigger
  • From Queue select the queue and choose Actions and select Configure Lambda trigger option and choose the function and save.
  • From Queue send a message and from lambda function console select monitoring
  • From Clound watch metrics you can see success rate and failure rate.
  • Choose view logs in Cloud watch and Choose the latest Log stream and You will be able to see the message that you have send from the queue.
  • You can also test the function without the queue. You can choose the function and from there you can select a test event and configure test event.
  • Select create new test event and from event template select Amazon SQS and write the event name and choose create.
  • Once the event is created Choose Test and you will get the message success and verify it in the cloud watch logs.


Send a message from Lambda and receive from the Queue:

  • From the lambda console choose the function and change the function code for send message and choose
  • Once deployed choose Test and check the console for any errors or execution succeeded.
  • From the Queue page choose the queue to which we have send data from lambda.
  • Choose Actionsand Send and Receive Messages. The console displays the Send and receive messages
  • Choose Poll for messages.Amazon SQS begins to poll servers to find messages in the queue. The progress bar on the right side of the Receive messages section displays the polling duration.
  • To delete messages, select the messages that you want to delete and then choose Delete.
  • In the Delete Messagesdialog box, choose Delete.


  • No labels