CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pulumi--aws

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources with infrastructure-as-code.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

sns.mddocs/core/

Amazon SNS

Amazon Simple Notification Service (SNS) is a fully managed pub/sub messaging service for application-to-application (A2A) and application-to-person (A2P) communication.

Package

import * as aws from "@pulumi/aws";
import * as sns from "@pulumi/aws/sns";

Key Resources

Topic

SNS topic for pub/sub messaging.

const topic = new aws.sns.Topic("notifications", {
    name: "app-notifications",
    displayName: "Application Notifications",
    tags: {
        Environment: "production",
    },
});

Topic Subscription

Subscribe to an SNS topic.

const subscription = new aws.sns.TopicSubscription("email-sub", {
    topic: topic.arn,
    protocol: "email",
    endpoint: "admin@example.com",
});

Common Patterns

SNS with Lambda Subscription

const subscription = new aws.sns.TopicSubscription("lambda-sub", {
    topic: topic.arn,
    protocol: "lambda",
    endpoint: lambdaFunction.arn,
});

new aws.lambda.Permission("sns-invoke", {
    action: "lambda:InvokeFunction",
    function: lambdaFunction.arn,
    principal: "sns.amazonaws.com",
    sourceArn: topic.arn,
});

SNS with SQS Subscription

const queue = new aws.sqs.Queue("notifications-queue");

const subscription = new aws.sns.TopicSubscription("sqs-sub", {
    topic: topic.arn,
    protocol: "sqs",
    endpoint: queue.arn,
});

new aws.sqs.QueuePolicy("queue-policy", {
    queueUrl: queue.url,
    policy: pulumi.all([topic.arn, queue.arn]).apply(([topicArn, queueArn]) =>
        JSON.stringify({
            Version: "2012-10-17",
            Statement: [{
                Effect: "Allow",
                Principal: "*",
                Action: "sqs:SendMessage",
                Resource: queueArn,
                Condition: {
                    ArnEquals: {
                        "aws:SourceArn": topicArn,
                    },
                },
            }],
        })
    ),
});

SNS with Encryption

const kmsKey = new aws.kms.Key("sns-key", {
    description: "SNS topic encryption key",
});

const topic = new aws.sns.Topic("encrypted-topic", {
    name: "encrypted-notifications",
    kmsMasterKeyId: kmsKey.id,
});

SNS with Message Filtering

const subscription = new aws.sns.TopicSubscription("filtered-sub", {
    topic: topic.arn,
    protocol: "sqs",
    endpoint: queue.arn,
    filterPolicy: JSON.stringify({
        eventType: ["order_placed", "order_shipped"],
        price: [{ numeric: [">=", 100] }],
    }),
});

Key Properties

Topic Properties

  • name - Topic name
  • displayName - Display name for SMS subscriptions
  • deliveryPolicy - Message delivery retry policy
  • kmsMasterKeyId - KMS key for encryption
  • fifoTopic - Enable FIFO topic
  • contentBasedDeduplication - Enable content-based deduplication (FIFO only)

Subscription Properties

  • topic - Topic ARN
  • protocol - Protocol (email, sms, sqs, lambda, http, https)
  • endpoint - Endpoint to receive messages
  • filterPolicy - Message filtering policy
  • rawMessageDelivery - Enable raw message delivery

Output Properties

  • id - Resource identifier
  • arn - Resource ARN
  • name - Topic name

Use Cases

  • Application Alerts: Send notifications for system events
  • Fan-Out Pattern: Distribute messages to multiple subscribers
  • Mobile Push: Send push notifications to mobile devices
  • Email Notifications: Send email alerts to users
  • Event-Driven Architecture: Decouple microservices

Related Services

  • SQS - Message queuing
  • Lambda - Event processing
  • CloudWatch - Alarms and monitoring
  • EventBridge - Event routing

Install with Tessl CLI

npx tessl i tessl/npm-pulumi--aws

docs

index.md

quickstart.md

README.md

tile.json