一键导入
sns
Manage Amazon SNS topics, subscriptions, and message publishing via AWS CLI.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Manage Amazon SNS topics, subscriptions, and message publishing via AWS CLI.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Manage AWS Certificate Manager certificates, validation, renewal, and import for ALB, CloudFront, and API Gateway via AWS CLI.
Manage Amazon API Gateway REST APIs, HTTP APIs, WebSocket APIs, stages, and deployments via AWS CLI.
Manage EC2 Auto Scaling groups, launch templates, scaling policies, and scheduled actions via AWS CLI.
Manage Elastic Load Balancers (ALB, NLB, CLB), target groups, listeners, and health checks via AWS CLI.
Manage AWS Organizations accounts, OUs, SCPs, and delegated administration via AWS CLI.
Manage Amazon SageMaker notebooks, training jobs, models, endpoints, and pipelines via AWS CLI.
| name | sns |
| description | Manage Amazon SNS topics, subscriptions, and message publishing via AWS CLI. |
| metadata | {"openclaw":{"emoji":"🔔","requires":{"bins":["aws"]}}} |
Use this skill for pub/sub messaging: creating and managing topics, subscribing endpoints (email, SMS, SQS, Lambda, HTTP), publishing messages, and managing platform applications for push notifications.
sns:* for full access, or scoped policies for specific operations# List all topics
aws sns list-topics \
--query 'Topics[].TopicArn' --output table
# Get topic attributes (ARN, subscriptions count, policy)
aws sns get-topic-attributes --topic-arn <topic-arn>
# List subscriptions for a topic
aws sns list-subscriptions-by-topic --topic-arn <topic-arn> \
--query 'Subscriptions[].{Endpoint:Endpoint,Protocol:Protocol,Status:SubscriptionArn}' \
--output table
# List all subscriptions
aws sns list-subscriptions \
--query 'Subscriptions[].{TopicArn:TopicArn,Endpoint:Endpoint,Protocol:Protocol}' \
--output table
# Get subscription attributes
aws sns get-subscription-attributes --subscription-arn <subscription-arn>
# Check SMS sending attributes (spend limit, default sender ID)
aws sns get-sms-attributes --attributes DefaultSMSType MonthlySpendLimit
# Publish to a topic (all subscribers receive it)
aws sns publish \
--topic-arn <topic-arn> \
--subject "Alert Subject" \
--message "Alert message body"
# Publish with different messages per protocol
aws sns publish \
--topic-arn <topic-arn> \
--message '{
"default": "Default message",
"email": "Detailed email message with formatting",
"sms": "Short SMS alert",
"lambda": "{\"key\": \"value\"}"
}' \
--message-structure json
# Publish to a FIFO topic
aws sns publish \
--topic-arn <topic-arn> \
--message "Ordered message" \
--message-group-id "<group-id>" \
--message-deduplication-id "<dedup-id>"
# Send a direct SMS (no topic needed)
aws sns publish \
--phone-number "+1234567890" \
--message "Your verification code is 123456"
# Publish with message attributes (for filtering)
aws sns publish \
--topic-arn <topic-arn> \
--message "Event notification" \
--message-attributes '{
"event_type": {"DataType": "String", "StringValue": "order_placed"},
"priority": {"DataType": "String", "StringValue": "high"}
}'
⚠️ Cost note: First 1M SNS requests free/month. SMS costs vary by country ($0.00645/msg US). Email delivery is $2 per 100K.
# Create a standard topic
aws sns create-topic --name <topic-name>
# Create a FIFO topic (name must end in .fifo)
aws sns create-topic \
--name <topic-name>.fifo \
--attributes '{"FifoTopic": "true", "ContentBasedDeduplication": "true"}'
# Subscribe an email endpoint
aws sns subscribe \
--topic-arn <topic-arn> \
--protocol email \
--notification-endpoint <email@example.com>
# Subscribe an SQS queue
aws sns subscribe \
--topic-arn <topic-arn> \
--protocol sqs \
--notification-endpoint <sqs-queue-arn>
# Subscribe a Lambda function
aws sns subscribe \
--topic-arn <topic-arn> \
--protocol lambda \
--notification-endpoint <lambda-arn>
# Subscribe an HTTPS endpoint
aws sns subscribe \
--topic-arn <topic-arn> \
--protocol https \
--notification-endpoint https://example.com/webhook
# Add a filter policy to a subscription (message filtering)
aws sns set-subscription-attributes \
--subscription-arn <subscription-arn> \
--attribute-name FilterPolicy \
--attribute-value '{"event_type": ["order_placed", "order_shipped"]}'
# Enable encryption on a topic
aws sns set-topic-attributes \
--topic-arn <topic-arn> \
--attribute-name KmsMasterKeyId \
--attribute-value alias/aws/sns
# Tag a topic
aws sns tag-resource \
--resource-arn <topic-arn> \
--tags Key=Environment,Value=production
🛑 DESTRUCTIVE — Always confirm with the user before executing any of these commands.
# Unsubscribe an endpoint
aws sns unsubscribe --subscription-arn <subscription-arn>
# Delete a topic (also removes all subscriptions)
aws sns delete-topic --topic-arn <topic-arn>
⚠️ Deleting a topic immediately removes ALL its subscriptions. This cannot be undone.
TOPIC_ARN="<topic-arn>"
# Subscribe multiple queues to the same topic
aws sns subscribe --topic-arn $TOPIC_ARN --protocol sqs \
--notification-endpoint <queue-1-arn>
aws sns subscribe --topic-arn $TOPIC_ARN --protocol sqs \
--notification-endpoint <queue-2-arn>
# Each queue needs a policy allowing SNS to send to it
# (configure via SQS set-queue-attributes with a Policy attribute)
# Create topic for alarms
TOPIC_ARN=$(aws sns create-topic --name ops-alerts --query 'TopicArn' --output text)
# Subscribe the ops team
aws sns subscribe --topic-arn $TOPIC_ARN --protocol email \
--notification-endpoint ops-team@example.com
# Use this topic ARN in CloudWatch alarm actions
# Subscribe order-service to only order events
aws sns set-subscription-attributes \
--subscription-arn <sub-arn> \
--attribute-name FilterPolicy \
--attribute-value '{"event_type": ["order_placed", "order_cancelled"]}'
# Subscribe shipping-service to only shipment events
aws sns set-subscription-attributes \
--subscription-arn <sub-arn> \
--attribute-name FilterPolicy \
--attribute-value '{"event_type": ["order_shipped", "order_delivered"]}'
| Error | Cause | Fix |
|---|---|---|
AuthorizationError | Missing IAM permissions | Check IAM policy for required sns: actions |
NotFound | Topic or subscription doesn't exist | Verify ARN with list-topics or list-subscriptions |
InvalidParameter on FIFO | Topic name doesn't end in .fifo | Append .fifo to the topic name |
Subscription stuck in PendingConfirmation | Recipient hasn't confirmed | Ask recipient to check email/click confirm link |
| SMS not delivered | Spending limit reached or number blocked | Check get-sms-attributes for limits; verify number format |
KMSAccessDenied | SNS can't access the KMS key | Update KMS key policy to allow sns.amazonaws.com |