Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best folder structure for a serverless project?

I'm starting to work on a new serverless project using AWS Lambda and API gateway.

What is the best way to organize my project, without being locked into one framework such as the serverless framework or chalice?

Here's what I'm using so far.

  • project-dir/
    • serverless.yaml (config file)
    • functions/
      • function1.py
      • function2.py
    • lib/
      • common_helper_functions.py
    • tests/
      • unit/
        • test1.py
        • test2.py
      • functional/
        • test1.py
        • test2.py
    • migrations
    • resources
      • cloudformation.templates.json

Do any of you recommend a better way to organize my project? Does each micro-service get a separate git repo? Am I missing other important folders?

like image 451
Murali Allada Avatar asked Nov 22 '16 19:11

Murali Allada


People also ask

What are the four core components of serverless development?

The four core components of serverless development are FaaS (Function As A Service), BaaS (Backend As A Service), API Gateway, and database.

What are the main key considerations when designing a serverless architecture?

A serverless compute service such as Lambda, Azure Functions, Auth0 WebTask, or Google Cloud Functions must be used to execute code. Do not run or manage any servers, VMs, or containers of your own. Your custom code should be entirely run out of FaaS to gain the most benefit.

Which of the following best describes serverless architecture?

A serverless architecture is a way to build and run applications and services without having to manage infrastructure. Your application still runs on servers, but all the server management is done by AWS.


1 Answers

Your structure looks good if a bit flat. I like putting code flows together. There are usually multiple functions to get to a result. Those should be grouped. Common functions that cross flows but don't cross projects go into a common folder in project. I base my repo organization on overall ideas. If lambdas cross projects they go in a common repo. Project specific stay in their repo.

Many times the hardest part of using a serverless architecture is finding the code being called. With a good logical grouping you will save yourself many headaches later.

like image 115
Lockless Avatar answered Nov 06 '22 00:11

Lockless