aws boto sns – get endpoint_arn by device token


Currently, If we want to add a device to an SNS application using:

There is an option that the device was already added in the past.
To verify if the device is already added, we’re using:

which is very inefficient and can not be scaled.

is there a boto sns function that get the device_token and returns the endpoint_arn if exists?
(None if not).


Amazon gives you the arn on the Error Message. You can parse it from there. Not optimal, but saves some db lookup.

error: SNS ERROR – Could not subcribe user to SNSInvalidParameter: Invalid parameter: Token Reason: Endpoint arn:aws:sns:us-east-[rest of the ARN Key] already exists with the same Token, but different attributes. Here is some coffe with regex ready to go

Leave a Reply