How to use codestar in a serverless project having a microservice architecture?

135 Views Asked by At

I'm totally new with AWS Serverless architecture.

I was trying to generate the project architecture, and I read about AWS codestar and how it can Easily create new projects using templates for AWS Lambda using Python (which is my case)

But I didn't know if I should :

  • generate one project (the main project ) with AWS codestar and then I create separate folders for every microservice I have (UsersService, ContactService ...etc)

OR

  • every microservice can be generated via AWS Codestar so each service is a separate codestar project for my lambdas ?

Maybe it's a very stupid question for some of you, please any help or usefull links are welcome.

Thanks

2

There are 2 best solutions below

2
On BEST ANSWER

This is generally your decision over how you deploy, although I feel like the general consensus will be option 2. I'll try to explain why.

Option 1 is what you would call a Monolith, this means everything for your app is all in one place. This might initially seem great but has a few limitations which I've detailed below:

  • All or nothing deployments, if you update a tiny part of the app you need to deploy everywhere.
  • Leads to coupling between unrelated components, generally the design pattern can lead to overlapping changes that can cause breaking changes for other parts of your stack.
  • Harder to scale, you generally scale larger chunks (i.e. not search and book independently but everything all together).

You can mitigate against these but it can be a bit of a headache.

The second option leads more towards a Microservice/Decoupled Architecture.

Some of the benefits of this method are:

  • Only deploy the changes you've made, if the search service changes only deploy that.
  • Easier to scale infrastructure to meet specific demand.
  • Able to implement functional testing of the component easier.
  • Restrict access to users who develop specific components.

Option 2 is your microservice based repository setup, so I would suggest using this.

0
On

I don't have enough reputation to comment so I will post this as an answer.

What you are asking about is software architecture question, and whether or not to use a monorepo vs a polyrepo. You've already made the decision about microservices, so this is not a monolith.

The answer is.... it depends. There is no general consensus. Just do search on monorepo vs polyrepo (or multirepo) and be prepared to go down the rabbit hole.

Being a serverless application should have no bearing on the type of structure you decide on. However, CodeStar may have some limitations that make it more difficult to use a monorepo. I'm using the CDK for that.

Here are a couple of articles to get you started:

https://medium.com/@mattklein123/monorepos-please-dont-e9a279be011b

https://medium.com/@adamhjk/monorepo-please-do-3657e08a4b70

Here is another that pertains directly to serverless applications:

https://lumigo.io/blog/mono-repo-vs-one-per-service/