Lambda not triggered by SNS publish > topics created programmatically

Hi!

I have a Lambda (lambda_a) subscribed to a topic, but it’s not been triggered on publish. I believe the problem is that, in the serverless.yml, I don’t have event > sns > arn:

If I put a topic arn, everything works as expected :slight_smile:

But here is the catch: my lambda_a subscribes and unsubscribes from topics through AWS API calls. I have another lambda (lambda_b) that generates a bunch of new topics at run time and lambda_a subscribes to them (this is actually working, I can see in SNS dashboard that lambda_a is subscribed to my_new_topic)

In other words, it looks like the problem is that I don’t have in serverless.yml event > sns > arn: my_new_topic, because I actually don’t have the topic at deploy time

Any thoughts on this? Thanks!

For reference, a snippet from my serverless.yml:

provider:
    iamRoleStatements:
      - Effect: Allow
        Action:
          - lambda:InvokeFunction
        Resource: "arn:aws:lambda:<region>:<number>:function:lambda_a"
      - Effect: Allow
        Action:
          - sns:*
        Resource: arn:aws:sns:<region>:<number>:*
functions:
    handle_sns_message:
        handler: handlers/my_handler:
        events:
          - http:
                path: some/path
                method: post
                authorizer: my_authorizer