-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for cross service communication via CloudFormation outputs #3575
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant 👏 !!! Love the simplicity!
Works like a charm 🎉
May I ask why we're not going with Since it has the following features (yes I find them features 😉 ):
|
We have enjoyed those features too. That said, we had also written a plugin for doing just this in a case where we were using CF outputs for a build process. Thanks! |
We also rely on the integrity provided by CF when using Fn::ImportValue. E.g. our VPC and network stack configurations are stored ina separate stack and referenced by the other SLS stacks. It would imply capital damage if the stack references were not protected and someone just deletes the network stack. |
@nicka the main reason is that We may still go with Just my two cents 😊 |
@eahefnawy Thanks for the response, and it does make sense! In any case it's a nice addition and we're all still free to use Off topic, we should really try to fix all area's where it's not possible to specify |
@nicka for sure! 👍 ... is there an issue open where we can track this? 😊 |
I must admit I'm not the biggest fan of I think both problems are related. |
That's available since forever. Pretty much everywhere where you can use intrinsic functions. functions:
fufu:
handler: fufu.handler
events:
- sns:
arn:
Fn::ImportValue: ${cf:service-a-dev.fufuTopicArn}
topicName: fufuTopic |
@nitely thanks for mentioning that. AFAIK some event definitions are still lacking behind because we had to implement this over and over again for every event in the past. Referencing #3212 here where we're discussing a global |
@eahefnawy @HyperBrain I've been playing around with a proof of concept on how to create large, domain/service separated serverless applications. The need for cross stack references is clear. There remains one big issue, no matter if you use You might feel like Is my explanation clear enough? From my perspective this is a huge issue that needs to be resolved for serverless to become an acceptable paradigm in larger projects. If you like, I could invite you to a private repo in which I am playing around with this concept. |
Hey @tommedema , I'm a heavy user of serverless and I've used it to create the kind of deployment you are referring to.
It does not. You must specify
Circular dependencies are the worst. If there is a resource |
@nitely thanks for your answer. You don't have to specify There is indeed no way to define dependencies across-stack. This is why I'm advocating that this should be built into Serverless Framework, because I don't see large projects being maintainable if you have to wait for remote dependency resolution errors to happen. Especially since resolving them is a nightmare. Consider this example of a circular dependency that's very real (it happened just 10 minutes ago). I have three services:
All of these services have so much domain-specific business logic that their serverless.yml files exceed ~150-200 lines. Therefore it's good to keep them separated. The circular dependency is here:
ssl --> web
web --> domain --> ssl Of course, circular dependencies cannot really be resolved, but the orchestration or order of deployment can. Currently this last part is done for references within stacks, but not between stacks. |
For policies you definitely have to. I don't know about ref, but for the sake of this conversation let's say you are right.
AFAIK, everyone has a stage just for deployment testing. No need for resolving them as you can just delete and create the whole thing gain for a second try. I know this is not ideal, but CF does not gives lots of tools for this. There has been some discussions about automatically splitting a serverless stack, but IMHO that's too ambitious. |
I think we have a different perception on what kind of developer experience would be acceptable for large projects. In my opinion, deploying to a review environment is supposed to be for manual and functional testing of the application, and for product owners to confirm expectations. It should not be for testing if deployment works. Especially considering how slow a serverless deployment is, this would be much worse than just not ideal. In my case for example, I run a tech department with a small team of about 20 developers and really want to make a shift to serverless in the future -- but this is currently holding us back. I imagine that for a larger company this is even more so the case. |
I think you have a different perception than AWS engineers, PMs or whoever make the calls. I wish CF had better recovering/rollback for failed deployments but it's not the case and avoiding them is not very realistic. Providing this as a third party is a way harder task. IMHO, automatic deployment far outweighs the cons of CF. |
Having seperate stacks for each resource fixes issues with re-deploying buckets/etc that already exist. It also splits up code and increases potential for re-using stacks. added 'deploymentBucket' property so that all stacks deployed to same bucket (created manually). References: https://forum.serverless.com/t/cross-stack-references/1402/2 (rationale for multiple stacks) serverless/serverless#3575 (PR showing how-to cross-stack-references)
What did you implement:
Closes #3442
This PR adds support for cross service/stack communication by utilising CloudFormation outputs as a new source for the variable system =>
${cf:stackName.outputKey}
How did you implement it:
Added a new CloudFormation source to the variable system that allows you reference any output values in any stack you specify. This way a user can define CF outputs in one service, and reference them in another.
How can we verify it:
You'll need two services to test communication:
deploy
service-a
thenservice-b
, you'll notice that the memory size of the hello function inservice-b
is now set to 512 instead of the default 1024, followingservice-a
config.Todos:
Is this ready for review?: YES
Is it a breaking change?: NO