How handle multiple environment for AWS SNS?

1.6k Views Asked by At

I have a server using intensively AWS SNS. Of course I have multiple environments (dev, QA, production, custom, etc.)

Knowing that SNS let you register only one endpoint per token (so, AFAIK, I can't have two differents Endpoints with the same token, even if created from different PlatformApplication), how could I manage separation between my different environments?

EDIT: all our environment are in the same AWS IAM account.

2

There are 2 best solutions below

1
On BEST ANSWER

SNS does allow you to subscribe multiple HTTP/HTTPS endpoints to a single Topic but it sounds like you need an SNS topic per environment so that the dev Topic dispatches requests to a dev HTTP endpoint.

The recommended AWS strategy for multiple environments in 2017 is to use multiple accounts -- one per environment. You can use consolidated billing for all of your accounts.

If you separated them then you would wind up creating an SNS topic for each environment and each would publish requests to the appropriate endpoint for that environment.

The single account solution would be to create one Topic per environment and to update your app config or environment variables to use the ARN appropriate to the environment.

3
On

If your platformApplication is android, then you can use the same GCM/FCM server key to create multiple platformApplicationARNs with different names(one per env I'd assume). If it is iOS, you would have a dev key and a prod key for one application. I doubt you will be able to create multiple platformApplicationARNs with the same key using different names. Try it, if it works you're set!

Next, you should be able to register the same deviceToken with each of these different platformApplicationARNs.(I have tried this, it worked). This behaviour is similar to one mobile device registering to different applications for notifications.