Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Amazon SNS using rest or soap api

Is there any way to access Amazon SNS using REST or SOAP API, instead of using SDKs. If there is any way, please suggest me.It will be a huge help for me.

Thanks In Advance.

like image 477
Karteek Avatar asked Oct 23 '25 17:10

Karteek


2 Answers

Yes, see https://docs.aws.amazon.com/sns/latest/api/API_Publish.html for example:

https://sns.us-east-2.amazonaws.com/?Action=Publish
&TopicArn=arn%3Aaws%3Asns%3Aus-east-2%3A698519295917%3AMy-Topic
&Subject=My%20first%20message
&Message=Hello%20world%21 
&Version=2010-03-31
&AUTHPARAMS

Where AUTHPARAMS is the result of the AWS Signature Version 4 signing process

like image 150
Adrian Baker Avatar answered Oct 26 '25 07:10

Adrian Baker


Yes, you can. The Amazon SNS API is accessible and works using an HTTP protocol. All SDKs are just utility tools to make this communication easier.

As you can see from the AWS SNS API docs here, it is a matter of sending a POST request with correctly formulated HTTP Headers and body.

POST / HTTP/1.1
x-amz-sns-message-type: Notification
x-amz-sns-message-id: da41e39f-ea4d-435a-b922-c6aae3915ebe
x-amz-sns-topic-arn: arn:aws:sns:us-west-2:123456789012:MyTopic
x-amz-sns-subscription-arn: arn:aws:sns:us-west-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55
Content-Length: 761
Content-Type: text/plain; charset=UTF-8
Host: ec2-50-17-44-49.compute-1.amazonaws.com
Connection: Keep-Alive
User-Agent: Amazon Simple Notification Service Agent

{
  "Type" : "Notification",
  "MessageId" : "da41e39f-ea4d-435a-b922-c6aae3915ebe",
  "TopicArn" : "arn:aws:sns:us-west-2:123456789012:MyTopic",
  "Subject" : "test",
  "Message" : "test message",
  "Timestamp" : "2012-04-25T21:49:25.719Z",
  "SignatureVersion" : "1",
  "Signature" : "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
  "SigningCertURL" : "https://sns.us-west-2.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
  "UnsubscribeURL" : "https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"
} 

You may learn how to sign and build correct requests in their docs (link provided above). So, you don't have to use SDK, and make your own requests. But, I would suggest using the SDK, since it addresses many security issues for you.

like image 42
Uzbekjon Avatar answered Oct 26 '25 05:10

Uzbekjon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!