AWS SQS Inlet

Prerequisites

Synadia Cloud

This how-to expects you to have a Paid Synadia Cloud account. Within Synadia Cloud, navigate to the Settings page within your account. You will see a toggle switch to enable connectors.

AWS SQS

Setting up SQS is not part of this getting started guide. Take a look at the SQS getting started guide to set up a queue. Make sure to take note of the queue URL and the AWS credentials. You will need them later.

Connect CLI

The connect CLI allows you to interact with Synadia Connect. You can download the latest version of the CLI from the Synadia Connect GitHub releases page.

The connect CLI will make use of your current nats context (if one is configured). If not, you will need to provide a context (--context=CONTEXT) or provide the server URL (--server=URL) and credentials (--creds=FILE) directly.

Build

An Inlet is a connector which reads data from an external system and writes it to NATS. Let's start by creating a simple inlet connecting AWS SQS with NATS.

For this we will be using the aws_sqs source. You can find more information about the source by running the following command:

connect library get wombat source aws_sqs

Generating an inlet

Nobody likes to write boilerplate code, so we have a generator to help you get started. Run the following command to create your first connector:

connect connector create sqs_input

To make getting started a bit easier, we have provided a few templates for you to start from. For this example it doesn't really matter which template you take since you will be replacing nearly everything in it.

Once a template is selected, it will be opened in your default editor. Since we are creating an inlet, our config should contain a source and producer section. The source section is where we define how to read data from the external system. The producer section is where we define how to write data to NATS.

Let's fill in the source and producer sections of our inlet. Here is an example:

description: A simple input reading from SQS
runtime: wombat:main
source:
  type: aws_sqs
  config:
    url: https://sqs.us-east-2.amazonaws.com/563342913055/connect-test-1
    region: us-east-2
    credentials:
      id: YOUR_AWS_ACCESS_KEY_ID
      secret: YOUR_AWS_SECRET_ACCESS_KEY
producer:
  core:
    subject: connect.inlet.aws.sqs
  nats:
    url: nats://demo.nats.io:4222
  threads: 1

Obviously, replace the url, region, id, and credentials fields with your own values. The core.subject field is the NATS subject on which the messages will be published. The nats.url field is the URL of the NATS server.

Saving the file and closing your editor will automatically upload the inlet definition to the cloud. Our next step will be to start the connector.

Start

Starting the inlet is as simple as running connect connector start sqs_input. You can check the status of the deployment by either running connect connector ls or connect connector status sqs_input.