SNS/SQS fanout with Terraform

With SNS you can easily publish an event and immediately deliver it to topic’s subscribers. With SQS you can decouple services and asynchronously process events. If you connect both services, you will get all benefits together.

Resources

Let’s create a SNS topic and two SQS queues.

Subscriptions

Everything should be connected.

Permissions

By default your topic cannot forward message to the queues. You need to add missing permissions to every queue as access policy.