{"id":1648,"date":"2020-03-11T17:08:23","date_gmt":"2020-03-11T14:08:23","guid":{"rendered":"https:\/\/artem.services\/?p=1638"},"modified":"2020-03-12T23:22:33","modified_gmt":"2020-03-12T20:22:33","slug":"1648","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1648&lang=en","title":{"rendered":"\u00a0AWS SNS &#8212; HTTP(S) Subscription: manual confirmation"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-214\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png\" alt=\"\" width=\"975\" height=\"450\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png 975w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-300x138.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-768x354.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-954x440.png 954w\" sizes=\"(max-width: 975px) 100vw, 975px\" \/><\/p>\n<p>When creating an <strong>HTTP<\/strong>\/<strong>HTTPS<\/strong> subscription in <strong>AWS SNS<\/strong>, you can observe that the subscription is hanging in the status: &quot;<strong>Pending confirmation<\/strong>&quot;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1639\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.27.22.png\" alt=\"\" width=\"2058\" height=\"96\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.27.22.png 2058w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.27.22-300x14.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.27.22-1024x48.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.27.22-768x36.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.27.22-1536x72.png 1536w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.27.22-2048x96.png 2048w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.27.22-954x45.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.27.22-1354x63.png 1354w\" sizes=\"(max-width: 2058px) 100vw, 2058px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>SNS<\/strong> to the specified <strong>URL<\/strong> makes a <strong>POST<\/strong> request in which it sends data in <strong>JSON<\/strong> format and expects to receive a key value in response: &quot;<strong>SubscribeURL<\/strong>&quot;. But if the application does not know how to respond to <strong>SNS<\/strong>, then you can enter the confirmation <strong>URL<\/strong> manually, but for this you need to find out.<\/p>\n<p>To do this, you can use <strong>Nginx<\/strong> and its <strong>access_log<\/strong>.<\/p>\n<p>Since the body of the <strong>POST<\/strong> request is written to the log only when using &quot;<strong>proxy_pass<\/strong>&quot;, we model proxing to the backend.<\/p>\n<h3>nginx.conf<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nuser  nginx;\r\nworker_processes  1;\r\n\r\nerror_log  \/var\/log\/nginx\/error.log warn;\r\npid        \/var\/run\/nginx.pid;\r\n\r\n\r\nevents {\r\n    worker_connections  1024;\r\n}\r\n\r\nhttp {\r\n    log_format postdata escape=json '&quot;$request_body&quot;';\r\n\r\n    server {\r\n        listen       80;\r\n        server_name  _;\r\n\r\n        location \/success {\r\n            return 200;\r\n        }\r\n\r\n        location \/ {\r\n            proxy_redirect off;\r\n            proxy_pass_request_body on;\r\n            proxy_pass $scheme:\/\/127.0.0.1:$server_port\/success;\r\n            add_header X-Body $request_body;\r\n            access_log  \/var\/log\/nginx\/post.log postdata;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<blockquote><p>In the example, the configuration is for the <strong>HTTP<\/strong> protocol, if you have <strong>HTTPS<\/strong>, add the parts of the configuration that are related to <strong>SSL<\/strong>.<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>Reload the <strong>Nginx<\/strong> configuration:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsystemctl reload nginx\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>After we return to the <strong>AWS<\/strong> console and select the necessary one in <strong>SNS<\/strong> subscriptions and make a one more request\u00a0 &quot;<strong>Request Confirmation<\/strong>&quot;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1640\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.50.20.png\" alt=\"\" width=\"2150\" height=\"662\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.50.20.png 2150w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.50.20-300x92.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.50.20-1024x315.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.50.20-768x236.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.50.20-1536x473.png 1536w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.50.20-2048x631.png 2048w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.50.20-954x294.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-15.50.20-1354x417.png 1354w\" sizes=\"(max-width: 2150px) 100vw, 2150px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Follow to <strong>Nginx<\/strong> log:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncat \/var\/log\/nginx\/post.log\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Interested in the value of the key: &quot;<strong>SubscribeURL<\/strong>&quot;, it will be of the form:<\/p>\n<pre>https:\/\/sns.{REGION}.amazonaws.com\/?Action=ConfirmSubscription&amp;TopicArn=arn:aws:sns:{REGION}:{YOUR_ACCOUNT_ID}:{YOUR_TOPIC_NAME}&amp;Token={YOUR_TOKEN}<\/pre>\n<p>&nbsp;<\/p>\n<p>We copy it and return to <strong>AWS SNS<\/strong>. Select &quot;<strong>Confirm Subscription<\/strong>&quot;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1641\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.35.png\" alt=\"\" width=\"2120\" height=\"470\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.35.png 2120w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.35-300x67.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.35-1024x227.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.35-768x170.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.35-1536x341.png 1536w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.35-2048x454.png 2048w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.35-954x212.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.35-1354x300.png 1354w\" sizes=\"(max-width: 2120px) 100vw, 2120px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Insert the value &quot;<strong>SubscribeURL<\/strong>&quot; and confirm.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1642\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.46.png\" alt=\"\" width=\"1196\" height=\"414\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.46.png 1196w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.46-300x104.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.46-1024x354.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.46-768x266.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-11-at-16.02.46-954x330.png 954w\" sizes=\"(max-width: 1196px) 100vw, 1196px\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When creating an HTTP\/HTTPS subscription in AWS SNS, you can observe that the subscription is hanging in the status: &quot;Pending confirmation&quot; &nbsp; SNS to the specified URL makes a POST request in which it sends data in JSON format and expects to receive a key value in response: &quot;SubscribeURL&quot;. But if the application does not &hellip; <a href=\"https:\/\/artem.services\/?p=1648&#038;lang=en\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;\u00a0AWS SNS &#8212; HTTP(S) Subscription: manual confirmation&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[599],"tags":[543,1307,409,345,1309,1311,1313],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1648"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1648"}],"version-history":[{"count":2,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1648\/revisions"}],"predecessor-version":[{"id":1652,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1648\/revisions\/1652"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}