Aws sns

From paulpas/agent-skill-router · View interactive version

Aws sns is an AI agent skill from the GitHub repository paulpas/agent-skill-router. Implements Amazon Simple Notification Service (SNS) for building and managing message-driven applications through an event-driven architecture.

How to use this skill

Skill file

Enhanced Content for AWS SNS Skill

Overview of Amazon SNS

Amazon Simple Notification Service (SNS) is a fully managed service for enabling message-driven application architectures with numerous advantages, including:

Core Features:

  1. Topic Management: Create and manage topics with ease for different messaging scenarios.
  2. Enhanced Security: Utilize IAM policies to control permissions and ensure secure access to your messaging resources.
  3. Integration with Other AWS Services: Integrate effortlessly with AWS Lambda, Amazon SQS, APIs, and more for creating dedicated workflows.

Security Best Practices:

Example: How to Use AWS SNS with Boto3

import boto3

# Create an SNS client
client = boto3.client('sns')

# Create a new SNS topic
response = client.create_topic(Name='MyTopic')

# Publish a message to the topic
response = client.publish(
    TopicArn=response['TopicArn'],
    Message='This is my first SNS message!',
)
print(response['MessageId'])

FAQs About AWS SNS Functionality:

Absolutely! AWS SNS supports the integration of mobile push notifications across various platforms including iOS and Android.

SNS can trigger Lambda functions upon message delivery, making it suitable for event-driven architectures.

Yes, SNS allows messages to be broadcasted to multiple endpoints, including SQS queues, Lambda functions, and HTTP endpoints.

By implementing AWS SNS strategies, businesses can efficiently manage messaging needs, enhance application decoupling, and ensure a secure and scalable infrastructure.


Pattern 2: SNS with Subscriptions and Message Filtering

import boto3
from typing import Optional


def create_topic_and_subscribe(client, topic_name: str, protocol: str, endpoint: str) -> dict:
    """Create an SNS topic with a subscription."""
    topic_resp = client.create_topic(Name=topic_name)
    topic_arn = topic_resp["TopicArn"]

    sub_resp = client.subscribe(
        TopicArn=topic_arn,
        Protocol=protocol,
        Endpoint=endpoint,
    )
    print(f"Created subscription: {sub_resp['SubscriptionArn']} for topic {topic_arn}")
    return {"topic_arn": topic_arn, "subscription_arn": sub_resp["SubscriptionArn"]}


def publish_with_attributes(client, topic_arn: str, message: str,
                             event_type: str = "general") -> dict:
    """Publish a message with attributes for subscriber filtering."""
    response = client.publish(
        TopicArn=topic_arn,
        Message=message,
        MessageAttributes={
            "event_type": {"DataType": "String", "StringValue": event_type},
            "priority": {"DataType": "String", "StringValue": "high"},
        },
    )
    print(f"Published message with attributes to {topic_arn}: {response['MessageId']}")
    return response


def get_topic_attributes(client, topic_arn: str) -> dict:
    """Get all attributes for an SNS topic."""
    return client.get_topic_attributes(TopicArn=topic_arn)

Constraints

MUST DO

MUST NOT DO

Live References

Authoritative documentation links for this domain. The model follows markdown links at load time to resolve external references and inline content.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.