How to connect AWS Eventbridge to an SNS topic

11.6k views Asked by At

I want an SNS topic to trigger an Eventbridge event, so that I can invoke an ECS task. I have tried to connect an Eventbridge rule to an SNS topic as follows (this is my event pattern for the eventbridge rule):

{
  "source": [
    "aws.sns"
  ],
  "region": [
    "eu-west-1"
  ],
  "resources": [
    "arn:aws:sns:eu-west-1:xxx:myTestTopicForECS"
  ]
}

However, when I publish a message to this topic, the Eventbridge rule doesn't get triggered. I have tried to see if anyone else has this problem, but haven't been able to find anything. How do I solve this?

2

There are 2 answers

1
Dmitri Kaminin On BEST ANSWER

@HolyM, He wants the SNS topic to act as a source to eventBridge, not a destination.

@Andreas Forslöw, you cant do it, because eventBridge listen to events of AWS resources, publish a message to the topic is not resource change.

Instead, you can subscribe to a topic with lambda which invokes an ECS task.

0
joshwa On

You could also write a small lambda that subscribes to the topic and uses the EventBridge PutEvents API.