Amazon SNS

AWS
Open Source

Publishes and distributes notifications across gateway instances using AWS SNS topics. Your backend services publish notifications to the SNS topic, and each Notiway instance subscribes to it via its Buffer plugin.

Source code: Notiway.Plugins.AWS.Brokers.SNS

Compatibility

Pairs withAmazon SQS Buffer
ProductNotiway Notify

Installation

Environment Variables

VariableRequiredDefaultDescription
Infra__Plugins__Broker__NameYesSet to SNS
Infra__Plugins__Broker__VersionYesPlugin version (e.g., 0.12.0)
Infra__Plugins__Broker__Config__TopicArnYesARN of the SNS topic to publish notifications to
Infra__Plugins__Broker__Config__RegionYesAWS region where the SNS topic is located (e.g., us-east-1)

AWS credentials are resolved using the default AWS credential chain (environment variables, IAM role, instance profile, etc.).

Infrastructure

Before starting Notiway, set up the following in AWS:

  1. Create an SNS topic — standard topic is recommended.
  2. Create an SQS queue for each Notiway instance (or a single queue for single-instance deployments).
  3. Subscribe each SQS queue to the SNS topic — this is how SNS fans out notifications to all instances.
  4. IAM permissions — the Notiway service needs sns:Publish on the topic. The SQS queue policy must allow the SNS topic to send messages.

Docker Compose

docker-compose.yml
services:
  notiway:
    image: notiway/notify:aws-0.6.0
    ports:
      - "5000:8080"
    environment:
      - Infra__Plugins__Broker__Name=SNS
      - Infra__Plugins__Broker__Version=0.12.0
      - Infra__Plugins__Broker__Config__TopicArn=arn:aws:sns:us-east-1:123456789012:notiway-topic
      - Infra__Plugins__Broker__Config__Region=us-east-1
      - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
      - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}

Usage

Publish notifications to the SNS topic from your backend using the AWS SDK. The message body must be the notification JSON.

var client = new AmazonSimpleNotificationServiceClient(RegionEndpoint.USEast1);

await client.PublishAsync(new PublishRequest
{
    TopicArn = "arn:aws:sns:us-east-1:123456789012:notiway-topic",
    Message = JsonSerializer.Serialize(notification)
});
import { SNSClient, PublishCommand } from "@aws-sdk/client-sns";

const client = new SNSClient({ region: "us-east-1" });
await client.send(new PublishCommand({
    TopicArn: "arn:aws:sns:us-east-1:123456789012:notiway-topic",
    Message: JSON.stringify(notification)
}));
import boto3, json

client = boto3.client("sns", region_name="us-east-1")
client.publish(
    TopicArn="arn:aws:sns:us-east-1:123456789012:notiway-topic",
    Message=json.dumps(notification)
)
SnsClient client = SnsClient.builder()
    .region(Region.US_EAST_1)
    .build();

client.publish(PublishRequest.builder()
    .topicArn("arn:aws:sns:us-east-1:123456789012:notiway-topic")
    .message(objectMapper.writeValueAsString(notification))
    .build());
#include <aws/sns/SNSClient.h>
#include <aws/sns/model/PublishRequest.h>

Aws::SNS::SNSClient client;
Aws::SNS::Model::PublishRequest request;
request.SetTopicArn("arn:aws:sns:us-east-1:123456789012:notiway-topic");
request.SetMessage(/* serialize notification as JSON */);
client.Publish(request);