AWS SNS HTTP subscription is not calling endpoint


AWS SNS HTTP subscription is not calling endpoint



I have deployed AWS SNS using Localstack in my dev machine and now I'm trying to consume messages I'm emitting from awslocal CLI (basically it's a aws against my local Localstack infra)


awslocal


aws



First, I have created a topic:


$ awslocal sns create-topic --name my-topic



Then, I've created a HTTP subcription against http://localhost:8080/sns/publish:


http://localhost:8080/sns/publish


$ awslocal sns subscribe --topic-arn "arn:aws:sns:us-east-1:123456789012:my-topic" --protocol http --notification-endpoint http://localhost:8080/sns/publish



I have a server running at localhost in port 8080 with a POST /sns/publish endpoint. It is supposed to be called in order to confirm the subscription. But it's never called.


localhost


8080


/sns/publish



I have some clues. I have deployed Localstack using Docker. After checking the container logs, I have seen this error:


2018-07-02T10:20:03:INFO:werkzeug: 127.0.0.1 - - [02/Jul/2018 10:20:03] "POST /sns/publish HTTP/1.1" 405 -



HTTP ERROR 405 corresponds to Method Not Allowed error so maybe it's trying to call a container endpoint instead of my host machine's endpoint.



How can I solve this?




1 Answer
1



Solved. It was a IP resolving problem beacuse of Docker networking.



I've created a subnet:


docker network create -d bridge --subnet 192.168.0.0/24 --gateway 192.168.0.1 mynet



And subscribe SNS against 192.168.9.1 instead of localhost:


192.168.9.1


localhost


$ awslocal sns subscribe --topic-arn "arn:aws:sns:us-east-1:123456789012:my-topic" --protocol http --notification-endpoint http://192.168.0.1:8080/sns/publish



Done!






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to make file upload 'Required' in Contact Form 7?

Rothschild family

amazon EC2 - How to make wp-config.php to writable?