skip to Main Content

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?

3

Answers


  1. Chosen as BEST ANSWER

    This issue is solved now. Our topic was a fifo topic and when we changed it to Standard Topic the subscribe function was working.


  2. 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.

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search