PubNub Integration

Amazon SQS – Fully managed message queues

Data Streaming & Dashboards

Data Streaming & Dashboards

Last Updated:





Fully managed message queues for microservices, distributed systems, and serverless applications

Amazon Simple Queue Service (Amazon SQS) offers a secure, durable, and available hosted queue that lets you integrate and decouple distributed software systems and components. Amazon SQS offers common constructs such as dead-letter queues and cost allocation tags. It provides a generic web services API and it can be accessed by any programming language that the AWS SDK supports.

Amazon SQS supports both standard and FIFO queues.


  1. Sign-up for an AWS account and setup the SQS queue(s).

  2. Sign-up for a PubNub account, if you don't have one already.

  3. Import the Integration Block into your PubNub account. You can choose to add this to an existing application or create a new one.

  4. Configure the Integration Block module code, connecting it to your AWS account:

    1. Create a Secret in PubNub Vault, named AWS_ACCESS_KEY_ID, with value equal to your AWS Access Key ID for this service.

    2. Create a Secret in PubNub Vault, named AWS_SECRET_KEY, with value equal to your AWS Secret Key for this service.

    3. Create a Secret in PubNub Vault, named AWS_REGION, with value equal to your AWS Region for the target queue .

    4. Create a Secret in PubNub Vault, named AWS_ACCOUNT_NUMBER, with value equal to your AWS Account ID for this service.

  5. Start the Integration Block module.

  6. Try a test message (you can click on Publish to do this).


After importing the Integration Block to your account, a new function called “Amazon SQS v1” will be setup to listen to a specific PubNub channel (CHANNEL-to-send-to-SQS),  but you can configure it to listen to all channels or a subset, using wildcards, e.g. chat.*.  

By default, the name of the queue that the function will write to is “pn_test”.   There are two ways that you can change the queue name:

  1. You can specify a different default queue name directly in your function code.   Modify your copy of the function code to specify the static queue name.   

At approximately line 34 you will see an object being defined:

const functions_config = {

        env: {

            'TARGET_QUEUE_NAME': 'pn_test',



        logger: {}


Change the value of 'TARGET_QUEUE_NAME' to your queue name, for example 'my_test_queue'

2. You can also overwrite the default queue name specified in the function code by publishing messages with additional metadata with the queue name. 

Example publish metadata:


"functions": {

"aws-sqs-v1": {

"input": {

"TARGET_QUEUE_NAME": “my_dyanamic_queue”

} } } }

Examples of how to publish messages with metadata can be found in the Publish documentation

Feedback & Support

Need help? Contact PubNub Support.

Talk to an expert

Contact Sales