Skipping resource from deployment

Hi,

Let’s assume we have a part of a system which consists of two Lambdas and SNS topic in between.
I would like to put that SNS topic in Serverless.yml file to ensure it is presented during deployment of any lambda (one Lambda write new messages, the second - consume messages).
What will happen if I add them to both Serverless.yml files?
Can we optionally skip creation of service during deployment?

Thanks

Are you suggesting that Lambda A triggers Lambda B using SNS and that Lambda A & B are in different projects? You can allow the project with Lambda B to create the SNS topic as a trigger for Lambda B then use cross stack references to access the ARN for the SNS topic from Lambda A in the other project.

Yeah, let’s assume these are different services.
The idea is to put all useful resources in Serverless.yml for every Lambda and if we have some shared resource it’s not clear what should we do.
I want to deploy Lambda A if SNS exists and deploy Lambda B if SNS exists, so I need to check it’s existance during both deployments.

What you want is a cross stack reference. You need to create the SNS topic in one project (stack) then import the ARN for it into the others. If you use the ${cf:stack.output} variable syntax then Serverless will warn you during deployment that it cannot resolve the cross stack reference if it doesn’t exist.

I would generally recommend creating the SNS topic in the stack that publishes the message (which is the opposite of what I described above). While it’s a little more difficult than allowing Serverless to automatically create the topic it makes more sense if you ever end up using fan out (i.e. publishing a message to an SNS topic triggers multiple Lambda in different stacks).

Looks interesting.
Will check it, thanks,