LoginSignup
1
3

More than 5 years have passed since last update.

AWS SNS で unsubscribe できないようにする

Last updated at Posted at 2018-09-17

AWS SNS で unsubscribe できないようにする方法

間違って unsubscribe しないようにするための手順メモ。

AWS CLI 環境を用意する

SNS トピック購読時の URL を用意する


https://sns.ap-northeast-1.amazonaws.com/confirmation.html?TopicArn=arn:aws:sns:ap-northeast-1:123456...

みたいな URL。

URL の構造

本当は一行だけど、パラメータごとに改行したら、以下のような感じ。


https://sns.ap-northeast-1.amazonaws.com/confirmation.html?
  TopicArn=arn:aws:sns:ap-northeast-1:1234567890:XXXXYYYYZZZZ&
  Token=やたら長いトークン&
  Endpoint=hogehoge@sample.com

前項の URL の情報からコマンドラインを作成する

本当は一行だけど、パラメータごとに改行したら、以下のような感じ。


aws sns confirm-subscription
  --topic-arn arn:aws:sns:ap-northeast-1:1234567890:XXXXYYYYZZZZ
  --token やたら長いトークン
  --authenticate-on-unsubscribe true
  --region ap-northeast-1

AWS CLI の環境で、前項で作成したコマンドを実行する


> aws sns confirm-subscription --topic-arn arn:aws:sns:ap-northeast-1:*** --token *** --authenticate-on-unsubscribe true --region ap-northeast-1

を実行して成功すると、以下のような出力が得られます。

{
    "SubscriptionArn": "arn:aws:sns:ap-northeast-1:***"
}

動作確認

購読した時の unsubscribe リンクを押してみる。(以下の「赤線」部分)

image.png

以下のように「Subscription not removed」と表示されて、無効化できていることが確認できます。

image.png

参考リンク

unsubscribe - AWS CLI
https://docs.aws.amazon.com/cli/latest/reference/sns/unsubscribe.html

Amazon SNS メール通知の「unsubscribe」リンクを無効化する
https://dev.classmethod.jp/cloud/aws/amazon-sns-disable-unsubscribe-link

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3