3

I am a newbie in microservices and done my research on the best practices and how to upgrade from monolithic. I need now concrete steps to move forward.

I am looking to upgrade a monolithic Laravel project to Microservices.

I have started to break the app into smaller apps. So developed multiple Laravel projects each representing a service. To simplify the question:

  • Authentication app: used for user authentication and registration
  • ToDo app: used to create a todo-list with tasks for a specific user

So now I have these two apps where each has its own CRUD operations (multiple APIs).

The question is how to move these apps to AWS serverless using Lambda Functions, API Gateways and Connect to PostgreSQL (Aurora DB).

  1. First I need either to use the SAM template or the Bref template? And how to handle that AWS Lamda does not support Laravel?
  2. Each app has several functions in it (the first app has signup, login, reset password...) so does each one of these must be an independent Lambda function? If yes does this mean each has to be a new Laravel project and then I will have to mention the same resource to be used by SAM or Bref to have the different functions to use the same DB.
  3. Lambda creates by default an API Gateway? If yes then shall I create a main API gateway accessible by the user-side which can call the other API gateways? (Main API Gateways filters the request and if related to authentication it redirects to Authentication Gateway that can interact with the different Authentication Lambda functions?

I Will later have definitely to add step functions with SNS queuing support but for now, I need to understand how to move the apps.

And finally, how would you recommend integrating CI/CD into the project?

Thanks for the help!

DevAntho
  • 39
  • 3
  • Moving into microservices is not an upgrade. Nor is it a downgrade. Depending on how badly written your monolith is or how good you are in migrating it to microservices, you could end up having a better or worse system than your current one. – Noel Llevares Sep 28 '21 at 04:47
  • Regarding your last note (SNS queuing support) I've had the same idea before and I've made a laravel package which helps me setup a communication bridge between any AWS resource using SQS and SNS. https://github.com/amranidev/micro-bus – Houssain Amrani Aug 18 '22 at 14:06

1 Answers1

1

You can follow the instructions on the Bref documentation, installing both packages.

composer require bref/bref bref/laravel-bridge --update-with-dependencies

To answer your second question, it is your own choice if you want to break it down to smaller individual lambda function, or use the entire app as a function. Both can work. You may also include multiple functions per application and use an API Gateway to route specific request to the respective lambda. If you decide do just have one function, then all requests just have to be routed to the same lambda. It's your choice.

Lambda doesn't create the API gateway by default, the serverless framework does it for you if you include the following lines in your serverless.yaml file. events: - httpApi: '*'

I would suggest you stick with one API gateway for a simpler routing configurations. You can configure the API Gateway to route different requests to different services.

Finally you can implement CI/CD with a pipeline, using a Git repo as a trigger and configure CodeBuild to deploy your app to Lambda.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Phillip C
  • 61
  • 2