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 Type | Purpose | Description |
---|---|---|
Channel Binding | Define SNS topic properties | Specifies the name, ordering, and other topic-level settings. |
Operation Binding | Configure message producers and consumers | Defines how an application subscribes to a topic, including filter policies. |
Message Binding | Message-level configurations | Reserved for future message-specific SNS configurations. |
Server Binding | Server-level configurations | Reserved for future server-specific SNS configurations. |
Supported Versions
Version | Status | Key Features |
---|---|---|
0.2.0 | Latest | Adds support for consumer-level identifiers. |
0.1.0 | Stable | Basic 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
.
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
.
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'