0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SNSサブスクリプションの解除防止設定方法

Posted at

【AWS】SNSサブスクリプションの解除防止設定方法

AWS SNSでは、通常サブスクライバーがメールの[購読解除リンク]からサブスクリプションを解除することができます。しかし、場合によっては意図しない解除を防止したいケースもあります。

本記事では、authenticate-on-unsubscribe オプションを用いた解除防止の手順を紹介します。

背景と目的

デフォルトでは、SNSのサブスクリプションは受信者の判断で自由に解除可能です。
これを防ぐには、**解除時にAWS認証が必要となるよう設定(認証付き確認)**する必要があります。

手順まとめ

1. SNSサブスクリプションの確認メールを送信する

aws sns subscribe --topic-arn <トピックARN> --protocol email --notification-endpoint <既存の通知先メールアドレス>
  • 送信されたメールに含まれるリンクから**一度確認(Confirm)**を行います。

2. 現在のサブスクリプション状態を確認

aws sns get-subscription-attributes --subscription-arn <サブスクリプションARN>
  • 出力の中にある以下の項目を確認:
"ConfirmationWasAuthenticated": "false"

false であれば、まだ解除防止設定が有効でない状態です。


3. サブスクリプションを認証付きで確認(解除防止を有効化)

送信されたメールのリンクに含まれる Token を使用します。

aws sns confirm-subscription --topic-arn <トピックARN> --token <メールに記載されたトークン> --authenticate-on-unsubscribe true
  • --authenticate-on-unsubscribe true によって、解除時にAWS認証が必須となります。

4. 設定が正しく反映されたかを再度確認

aws sns get-subscription-attributes \
  --subscription-arn <サブスクリプションARN> \
  --region ap-northeast-1
  • 以下のように true となっていれば成功です:
"ConfirmationWasAuthenticated": "true"

必要情報のメモ

項目 説明
トピックARN SNSトピックのAmazonリソース名
サブスクリプションARN サブスクリプションのARN
トークン 確認メール内のリンクに含まれる値

補足

  • この設定を行っても、SNSトピック側での削除や、管理者による強制削除は可能です。
  • あくまで「サブスクライバー自身の解除操作を防止する」ためのものです。

まとめ

SNSサブスクリプションを守ることで、意図しない通知の停止を防ぐことができます。
運用上、メール通知を確実に継続したいケースでは、ぜひこの設定を取り入れてみてください!


0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?