I have a monorepo setup using lerna that contains both client-side and server-side code in different folders. I want to use the serverless framework to deploy everything together under one CloudFormation stack.
My project structure looks like this:
package.json
.. [modules]
.... [api]
...... package.json
.... [webapp]
...... package.json
I’m confused about the configuration. Should I create one serverless.yml file at the root level or have separate config files in each folder? If I use multiple configuration files, how do I make sure they deploy to the same CloudFormation stack name?
What’s the best approach to configure the serverless.yml to handle both parts of my application? I need them to work together but they have different deployment requirements.
I ran into the same issues deploying a full-stack serverless app. It really depends on what you need. A single serverless.yml at the root works if you want everything unified - just set up multiple functions and resources sections for both parts. But since you’ve got different deployment needs, I’d go with separate configs and share resources through CloudFormation outputs/imports. Set up a base serverless.yml for shared stuff like your database or API Gateway, then reference those in your api and webapp configs. You get cleaner separation but can still share resources. Just stick to consistent naming and use CloudFormation’s import/export features to keep your stacks connected.
i’ve done this b4 - used separate serverless.yml files with the same service name and stage. keep service + stage identical so both configs hit the same CloudFormation stack. works great, just watch ur deploy order if there are dependencies.
cool setup! why’d you pick lerna for this? and are you thinking different runtimes - like node.js for the api and static hosting for the webapp? that’ll probably decide whether you want one serverless config or split them up.