Yan Cui
2 min readJun 22, 2019

--

For sharing code within a bounded context, e.g. a service or API made out of multiple functions, you can have them in the same repo, like I have the lib folder in this repo.

And in one of my functions, I just need to reference them:

If you’re using something like the serverless framework, it bundles all the functions into a single zip file so all the functions have access to the shared code.

For sharing code across service boundaries, you can still use NPM or whatever package managers.

Having single purposed functions doesn’t mean you have to copy-and-paste shared code. If you’re using something like the serverless framework, then it’s already bundling all the files in the repo as a single artefact, so all your functions in the same API would have access to the shared code. But you still get the benefit of having single-purposed functions.

The serverless framework is about the one and only tool I use for all my serverless development. It handles all the packaging, uploading to S3 and deployment (via CloudFormation) for me. I don’t need big frameworks (like express.js) anymore. Compared to the amount of tooling I used to carry around with me — docker, docker-compose, Terraform, express.js, etc. — development tooling is much lighter for serverless, which also means less brain drain on remembering how all these tools work!

--

--

Yan Cui
Yan Cui

Written by Yan Cui

AWS Serverless Hero. Follow me to learn practical tips and best practices for AWS and Serverless.

No responses yet