Home > Software engineering >  SNS Topic Types
SNS Topic Types

Time:09-02

Can we create sns topic for application? I asked this because I have seen only examples that use Protocol='email' or 'sms' for subscribing to the topic using boto3. The requirement I have is that I want to create a topic and will subscribe to this topic using Endpoint Arn. So that when I publish notification to this topic it will be broadcasted to all its subscribers. So is it possible?

CodePudding user response:

To reproduce your situation, I tried this code:

import boto3

sns_client = boto3.client('sns')

response = sns_client.subscribe(
    TopicArn='arn:aws:sns:ap-southeast-2:123456789012:foo',
    Protocol='application',
    Endpoint='arn:aws:sns:us-west-2:123456789012:app/GCM/MyApplication'
)

print(response)

I don't have a valid EndpointARN for a mobile app, so I received the error:

botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameter) when calling the Subscribe operation: Invalid parameter: Application endpoint arn invalid:arn:aws:sns:us-west-2:123456789012:app/GCM/MyApplication

However, it does prove that Protocol='application' is accepted as valid input.

I am using boto3 version 1.24.38.

CodePudding user response:

There are only two types of topics: Standard-Topics and FIFO (First in, first out) Topics.

What you're referring to is the subscription. You can subscribe to an SNS topic using a variety of protocols:

  • HTTP/HTTPS
  • Email/Email-JSON
  • Amazon Kinesis Data Firehose
  • Amazon SQS
  • AWS Lambda
  • Platform application endpoint (Mobile Push Notifications)
  • SMS

Read the docs for more details: To subscribe an endpoint to an Amazon SNS topic

From your vague description, you're probably looking for an HTTP/HTTPS subscription.

  • Related