I'm developing backend for web application. The backend is split into several modules e.g. orders, products, etc. These modules share some common resources such as DynamoDB table, SNS topic. I'd like to be able to deploy the modules independently. What is the best practice for this scenario? Should the API Gateway be common for all modules or each module should have its own API Gateway? Thanks for your replies
-
How does your deployment process look like? Do you have a CI/CD pipeline? Do you do it manually from the command line (e.g. `sam deploy`)? Something else? – Milan Cermak Jan 24 '19 at 19:10
-
So far I do it manually via SAM CLI. However I'm going to automate the deployment process using CI/CD pipeline (CodePipeline, CodeBuild) – bikerp Jan 27 '19 at 12:22
1 Answers
I would start simple and keep everything inside a single SAM template and single API Gateway and a single repository. When deploying with SAM / Cloudformation, only the resources that got modified are updated, so there's no overhead.
It's also easier to build your CD pipeline this way. You can achieve independent module deploys by only committing and pushing changes of that module.
Once (if) you overgrow a single-template-infrastructure model, it's not overly difficult to separate your resources to multiple templates and cross-reference shared resources using the Outputs
and !ImportValue
functionality of Cloudformation. What can be difficult is synchronizing dependent deploys (i.e. function A in module 1 needs function B in module 2 to work correctly and vice versa), but that's an issue for another day.

- 7,476
- 3
- 44
- 59