Event Consumer and Producer App
Use of external data services in AWS will make charges your account. Please make sure to perform the cleanup per the notes at the bottom of the lab.
The following Lab will demonstrate how to integrate Amazon SQS and Amazon SNS into a simple application that displays messages from a queue and publishes a message to an Amazon SNS Topic. The Amazon SNS Topic will send an email to a defined email address.

Requirements
To develop this application the following requirements will be required.
- AWS Account with Administrative user
 
Steps
Create AWS Identity and Access Management Policies
First we need to configure permissions in AWS to allow access to Amazon SQS and Amazon SNS. This required portion of the lab is available as a separate artifact in AWS IAM Role.
Create Amazon SQS Queue
Next an Amazon SQS queue needs to be created. This required portion of the lab is available as a separate artifact in Amazon SQS.
Create Amazon SNS Topic
With the Amazon SQS queue created, an SNS Topic will be defined. This required portion of the lab is available as a separate artifact in Amazon SNS.
Create a simple app
Once the resource have been created we first will create a query to read from an Amazon SNS queue.
Create App
- Let's display the SQS Message as a Text Input component and a Button component below it.
 - Update the Label to 
SQS Queue. - Update the Button text to 
Get event. - For the SNS Message, place a Text Input component below the previous Text Input / Button components.
 - Update the Label to 
SNS Topic. - Update the Button text to 
Publish event. 
The following demonstrates the previous steps:
Create SQS Query
- Go to Code > + > Resource Query and specify a query name of 
getEventFromSQS. - Select Resource set to 
Amazon SQS resource, Action type set toReceive messages from queue, and a Queue ofRetoolQueue. 
Note if you want Retool to automatically poll the queue, go to Advanced > Run this query periodically > specify time setting.
- Once we have the query completed, we need to populate a message in Amazon SQS.
 
The following demonstrates the previous steps:
Create SNS Query
Unlike SQS, Retool's SNS Resource will only publish a message to a topic.
- Go to Code > + > Resource Query and specify a query name of 
postEventToSNS. - Select Resource set to 
RetoolUniversitySNSTopic, a Topic ofRetoolTopicand a message of{{SNSMessage.value}}. 
The following demonstrates the previous steps:
Event Handlers
- Next we create event handlers for each Button component to invoke the 
getEventFromSQSandpostEventToSNSqueries. 
The following demonstrates the previous steps:
Create test message using Amazon SQS
- Go to the AWS Management Console and select Amazon SQS.
 - In Amazon SQS go to the 
RetoolQueueand select Send and receive messages. - In Message body enter a message:
 
Hi Retool! This is Amazon SQS queue sending you a quick hello!
- Select Send message. This will place message into the queue.
 
The following is an image of the AWS Management Console with Send Message content:

Test App
- Select the 
Get eventbutton and a message should display in the text component. - Enter a value into the Publish event text input.
 
Hi Amazon SNS topic! This is Retool sending you a quick hello!
- Select the 
Publish eventbutton. - This will generate an email that you will receive in your email inbox.
 
The following demonstrates the previous steps:
This results in an email notification to the configured endpoint(s).
