serverless-heaven / serverless-aws-alias

Alias support for Serverless 1.x

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subscribe to existing SNS topic

zachboyd opened this issue · comments

I am trying to subscribe to an existing SNS topic with the serverless-aws-alias plugin installed. When using an existing SNS topic it doesn't look like the subscription is actually created. I was able to replicate this using serverless 1.25 and serverless-aws-alias 1.5.1.

When navigating to the lambda alias and looking at the SNS trigger a message is shown on the bottom stating

"A subscription for arn on the topic topic name could not be found". The console gives an option to fix or delete.

Under CloudFormation resources I do not see an AWS::SNS::Subscription defined either.

It does work as expected with the alias plugin commented out in serverless.yml

Can you check, if the SNS subscription is placed into the alias stack? It should be created there, because the alias is subscribed and not $LATEST.

Did it also not show up when you inspect the aliased version of the lambda instead of $LATEST?

I actually see the AWS::SNS::Subscription resource on the non-aliased stack and to further validate when looking at the subscription registered on the SNS topic it doesn't look it has the alias on the end of the arn.

Also should mention that this is just a straight sls deploy without specifying an explicit alias so this is for the default alias dev.

Ok. Then this is a bug in the plugin, that it does not adjust the subscription to point to the alias. Additionally, the alias should have a permissions object attached. Can you post the relevant parts of your serverless.yml, just to be sure?

Here is the entire serverless.yml. I went ahead and replicated using a sample project that I created.

service: serverless-alias-test

plugins:

  • serverless-aws-alias

provider:
name: aws
runtime: nodejs6.10

functions:
snsalias:
handler: handler.snsalias
events:
- sns: arn:aws:sns:us-east-1:XXXXXXXXXXXX:sns-alias-test

Released with 1.6.0

I'm getting sporadic failures of a similar nature. Click on 'Fix' then 'Save' does indeed fix the issue, but having to add a manual verification of SNS subscriptions to our deployment process obviously sucks.

image

Context: I have a notifiers stack in my app that subscribes to topics defined in other services. Some of the subscriptions work, some don't. No discernible pattern to the failures. Checked the underlying CF templates and they look as they should. I was able to find two similar complaints in the SLS forum, but no answers. Commenting on this issue to see if I'm the only one or what.