Skip to content

Amazon SNS Bindings ​

Amazon Simple Notification Service (SNS) is a fully managed publish-subscribe (pub-sub) messaging service that enables you to decouple and scale microservices, distributed systems, and serverless applications. AsyncAPI provides bindings for SNS to define how your event-driven APIs interact with SNS topics.

What is Amazon SNS? ​

SNS allows you to send messages to a large number of subscribers through a single endpoint, the "topic." Subscribers can include AWS Lambda functions, SQS queues, HTTP endpoints, and more. It's designed for high-throughput, push-based, many-to-many messaging.

AsyncAPI SNS Bindings Overview ​

AsyncAPI SNS bindings map your API specification to SNS concepts:

Binding Types ​

Binding TypePurposeDescription
Channel BindingDefine SNS topic propertiesSpecifies the name, ordering, and other topic-level settings.
Operation BindingConfigure message producers and consumersDefines how an application subscribes to a topic, including filter policies.
Message BindingMessage-level configurationsReserved for future message-specific SNS configurations.
Server BindingServer-level configurationsReserved for future server-specific SNS configurations.

Supported Versions ​

VersionStatusKey Features
0.2.0LatestAdds support for consumer-level identifiers.
0.1.0StableBasic support for topic configuration and subscription policies.

Key SNS Concepts ​

Topics ​

A communication channel to send messages and subscribe to notifications. It provides a logical access point and a unique Amazon Resource Name (ARN).

Publishers and Subscribers ​

Publishers produce and send messages to topics. Subscribers (e.g., web servers, email addresses, SQS queues) consume these messages.

Message Filtering ​

SNS subscription filter policies allow subscribers to receive only the messages they are interested in, rather than every message sent to the topic.

Getting Started ​

Basic Channel (Topic) Configuration ​

This example defines an SNS topic named user-updates.

yaml
channels:
  userUpdates:
    bindings:
      sns:
        name: user-updates
        ordering:
          type: standard
        bindingVersion: '0.1.0'

Basic Operation (Subscription) Configuration ​

This example defines a subscription to the user-updates topic with a filter policy. The subscriber will only receive messages where the eventType attribute is user.created.

yaml
operations:
  onUserUpdate:
    bindings:
      sns:
        consumers:
          - protocol: sqs
            endpoint:
              name: user-updates-queue
        policy:
          statements:
            - effect: Allow
              principal: '*'
              action: 'sns:Subscribe'
        filterPolicy:
          eventType:
            - user.created
        bindingVersion: '0.1.0'

Binding Documentation ​

Channel Bindings ​

Operation Bindings ​

Message Bindings ​

Server Bindings ​