ablog

不器用で落着きのない技術者のメモ

AWS Simple Notification Service (SNS) を使ってみる

  • トピックを作成する
$ aws sns create-topic --name topic1
{
    "TopicArn": "arn:aws:sns:ap-northeast-1:<ユーザーID>:topic1"
}
  • トピックをリスト表示する
$ aws sns list-topics
{
    "Topics": [
 (中略)
       {
            "TopicArn": "arn:aws:sns:ap-northeast-1:<ユーザーID>:topic1"
        }
    ]
}
  • S3にファイルアップロードされたらメール通知されるよう設定する
$ aws sns subscribe --topic-arn arn:aws:sns:ap-northeast-1:<ユーザーID>:topic1 --protocol email --notification-endpoint ******@gmail.com
{
    "SubscriptionArn": "pending confirmation"
}
  • トピックにメッセージを送る。
$ aws sns publish --topic-arn arn:aws:sns:ap-northeast-1:<ユーザーID>:topic1 --message "hello" 
{
    "MessageId": "76ef3606-809d-5182-b684-67cfe594e762"
}