serverless-heaven / serverless-aws-alias

Alias support for Serverless 1.x
MIT License
189 stars 68 forks source link

Subscribe to existing SNS topic #94

Closed zachboyd closed 6 years ago

zachboyd commented 6 years ago

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

HyperBrain commented 6 years ago

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?

zachboyd commented 6 years ago

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.

zachboyd commented 6 years ago

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

HyperBrain commented 6 years ago

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?

zachboyd commented 6 years ago

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

service: serverless-alias-test

plugins:

provider: name: aws runtime: nodejs6.10

functions: snsalias: handler: handler.snsalias events:

HyperBrain commented 6 years ago

Released with 1.6.0

obie commented 5 years ago

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.