Amazon SNS (Simple Notification Service)

Overview

Amazon SNS is a fully managed pub/sub messaging service for decoupling microservices, distributed systems, and serverless applications.

Real-life Use Cases

  • Cloud Architect: Design event-driven architectures for microservices.

  • DevOps Engineer: Send deployment notifications to Slack or email.

Terraform Example

resource "aws_sns_topic" "alerts" {
  name = "alerts-topic"
}

resource "aws_sns_topic_subscription" "email" {
  topic_arn = aws_sns_topic.alerts.arn
  protocol  = "email"
  endpoint  = "devops@example.com"
}

AWS CLI Example

aws sns create-topic --name alerts-topic
aws sns subscribe --topic-arn arn:aws:sns:us-east-1:123456789012:alerts-topic --protocol email --notification-endpoint devops@example.com

Best Practices

  • Use topics for decoupling services.

  • Secure topics with access policies.

Common Pitfalls

  • Not confirming subscriptions.

  • Overusing email notifications (spam risk).

Joke: Why did the SNS topic get so many emails? It couldn’t unsubscribe from its own notifications!

Last updated