Function subscribing to existing SNS topic

Having a problem with a function subscribing to a pre-existing SNS topic. sls deploy is giving me the follow error:

Serverless Error ---------------------------------------

     An error occurred while provisioning your stack: SNSTopicArnawssnsuseast1092238776114sendtransmissiondev
     - Invalid parameter: Topic Name.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues

  Your Environment Infomation -----------------------------
     OS:                 darwin
     Node Version:       6.6.0
     Serverless Version: 1.0.3

with the relevant part of serverless.yml:

  updateStatusSubmitted:
    handler: handler.updateStatusSubmitted
    description: update the application status in ES to reflect submission of the application
    events:
        - sns: ${self:custom.writeEnvVars.SNS_ARN_BASE}send-transmission-${self:custom.stage}

I have created the subscription outside serverless so the function already has a subscription to the topic.

Any thoughts? This deployed once without error, but now gives this error.

1 Like

I’m having the same issue. Documentation says when specifying the arn serverless tries to create only the permission, but it seems to try to create the whole SNS topic.

not fixed in serverless 1.1.0 - still getting the same error

I had the same issue, try:

updateStatusSubmitted:
    handler: handler.updateStatusSubmitted
    description: update the application status in ES to reflect submission of the application
    events:
        - sns:
            topicArn: ${self:custom.writeEnvVars.SNS_ARN_BASE}send-transmission-${self:custom.stage}

Hello,

We still have the issue from the OP with the 1.4.0 and the following solution doesn’t work either:

- sns
    topicArn: ... 

Any solutions?

Best,
Jean

Hi all,

I was having this problem - in the same day that I was able to update the stack numerous times… I realised that I was doing the deploy in a new terminal which was using the latest Node version (default for NVM was 7.0.0), so tried rolling back to Node version 4.3.2 and hey presto - the deploy was working again.

So you may want to try a different version of NodeJS :slight_smile: