0

I tried a lot. I followed the post https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html also make my ec2 security group inbound change to anywhere http port 80.

I have also taken help from the similar question here How can i confirm the subscription request HTTP from amazon SNS also here Cannot get HTTP subscription confirmation request

in views.py

def unsub(request):
    content = ""
    if request.POST:
        json1 = request.body.decode('utf-8')
        print(json1)
        f = open('home/json.py','w')
        f.write(json1)
        f.close()

    f = open('home/json.py','r')
    content = f.read()
    f.close()
    return render(request,'home/json.html',{'content':content})

in urls.py

 urlpatterns = [
     path('unsub2',views.unsubscribe,name="unsubscribe"), 
 ]

here is my json.html,

<html>
 <head>
 </head>
 <body>
  <p>{{content|safe}}</p>
   <form method="post">
     <input type="text" name="i1" id="i1"></input>
     <input type="text" name="i2" id="i2"></input>
     <button type="submit" >submit</button>
   </form>
  </body></html>

I have subscribed the sns topic to the http endpoint http://my-ec2-domain.com/unsub2 but I am not getting any response to the page also not any in logs.Please tell me where I did wrong. python 3.5 django 2.1.

tarun sahu
  • 137
  • 1
  • 1
  • 10

1 Answers1

0

I figured it out. Although I have changed the security groups settings of the instances, I forgot to add the SNS service ip in the allowed host of settings.

tarun sahu
  • 137
  • 1
  • 1
  • 10