はじめに
Amazon SNSトピックに登録したEMAILエンドポイントに送られてくるメッセージ内に記載されている、アンサブスクライブリンクを無効化にする方法を本記事にて紹介します。
方法1:サブスクリプション登録用のURLをAWSコンソールにて登録する
①Amazon SNSトピックにてサブスクリプションの作成後、EMAILエンドポイントに「AWS Notification – Subscription Confirmation」という件名でサブスクリプション登録用のURL送られてきます。
②このURLをクリックせずにAWSコンソールのSNSトピック画面の「サブスクリプションの確認」にて登録します。
試しにアンサブスクライブリンクを押下してみる。
方法2:AWS CLIを利用する
①「ConfirmationWasAuthenticated」の値を確認します。
値が「true」→アンサブスクライブリンクが無効
値が「false」→アンサブスクライブリンクが有効
$ aws sns get-subscription-attributes --subscription-arn {サブスクリプションARN} { "Attributes": { "SubscriptionPrincipal": "arn:aws:iam::xxx:role/xxx", "Owner": "xxx", "RawMessageDelivery": "false", "TopicArn": "arn:aws:sns:ap-northeast-1:xxx:xxx", "Endpoint": "xxx", "Protocol": "email", "PendingConfirmation": "false", "ConfirmationWasAuthenticated": "false", "SubscriptionArn": "arn:aws:sns:ap-northeast-1:xxx:xxx:xxx" } }
②「ConfirmationWasAuthenticated」を「True」にします。
トークンはサブスクライブURLに埋め込まれています。
aws sns confirm-subscription --topic-arn {トピックARN} --token {トークン} --authenticate-on-unsubscribe true
③「true」になったか確認
$ aws sns get-subscription-attributes --subscription-arn {サブスクリプションARN} { "Attributes": { "SubscriptionPrincipal": "arn:aws:iam::xxx:role/xxx", "Owner": "xxx", "RawMessageDelivery": "false", "TopicArn": "arn:aws:sns:ap-northeast-1:xxx:xxx", "Endpoint": "xxx", "Protocol": "email", "PendingConfirmation": "false", "ConfirmationWasAuthenticated": "true", "SubscriptionArn": "arn:aws:sns:ap-northeast-1:xxx:xxx:xxx" } }
試しにアンサブスクライブリンクを押下してみる。
さいごに
うっかりアンサブスクライブしてしまうことを防ぐためにも、リンクを無効化することをお勧めします。
リンクを無効化することにより、AWSコンソールからのアンサブスクライブのみ可能となります。
お疲れ様でした。
参考:
https://docs.newrelic.com/jp/docs/logs/ui-data/query-time-parsing/