Recommended Project Structure for multi-function SAM Template
Asked Answered
J

1

6

I have a new project that requires a relatively small amount of services, maybe 10 or less (and therefore it is not economical to place each in a separate project repository). Each service will be defined as an AWS::Serverless::Function via SAM Template. My question is: what is the recommended way to organize or structure such a project?

Currently the structure is:

|- src
    |- lambdas
        |- service-one
            |- stuff
            |- package.json
        |- service-two
            |- stuff
            |- package.json
    |- other-stuff
|- test
|- package.json

Is there a way to avoid having each lambda act as its own sub-project with unique package.json and etc?

Jayjaycee answered 15/7, 2018 at 23:52 Comment(1)
I think you dont need separate package.json for each project, because all this functions will be deployed with "sam package / sam deploy" in one request to asw cloudformation. If you find out new info about best practices for project structure, please, share it in comment.Etherealize
S
0

I have designed the structure of my project like below

ProjectName
├── dependencies
│   └── package-pandas-requests.zip
├── deploy.sh
├── infrastructure
│   ├── packaged.yaml
│   └── template.yaml
└── src
    └── lambdas
        ├── lambdafunction1
        │   └── app.py
        ├── lambdafunction2
        │   └── app.py
        ├── lambdafunction3
        │   └── app.py

dependencies are layers package infrastructure for yaml files of SAM framework Hope this will clear your doubt.

Silence answered 10/3, 2020 at 11:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.