Serverless (AWS Lambda) MicroServices with legacy Magento 2

Create Magento lambda function. And configure VPC setting to have accesses to the same AWS resources as EC2 Magento Web Nodes has.

https://us-west-2.console.aws.amazon.com/lambda/home

Image for post
Image for post
Create Lambda Function

Enter Function Name somethin like “ProductAPI” -> Press “Create Function”

Image for post
Image for post

Ready:

Image for post
Image for post

Setup VPC Network settings:

Image for post
Image for post

Import function to Cloud9 code editor. Without Cloud9 you need to swallow a lot of dust to upload code and debug function. feature Cloud9 provides:

  • Create a new function from within your environment, uploading the local version of the function to Lambda, and optionally creating additional AWS resources to support the new function at the same time.
  • Run and debug a function and its related API in your environment, running the function and API completely within the environment.
  • Run the remote version of a function and its related API within your environment, running the remote version completely within Lambda and API Gateway.
  • Import an existing function in Lambda into your environment, so that you can run and debug the function and its related API, edit the code, or both.
  • Upload changes you make to the local version of the function code to the remote version in Lambda.

You can also create lambda function from Cloud 9 but it has fewer settings(VPC) than AWS web interface.

Create Lambda with Cloud9 ->AWS Resources->Add Lambda

Image for post
Image for post
Create Lamda with Cloud9

Ok let’s go.

We also should open MySQL port access in the Securety Groop getting to our Magento RDS. You can also use IAM Role authentification. Whatever you want.

Cloud Nine to an existed instance via SHH

https://docs.aws.amazon.com/cloud9/latest/user-guide/ssh-settings.html

IAM Identification:

Lamda should have Permissions policies “AmazonRDSFullAccess

Image for post
Image for post

Lambda as a target:

Image for post
Image for post

The path should start without ‘/’

After you are just writing your Magento microservices code using high-performance languages GO, Rust, Python, Java, #.Net, Node.JS without any platform limitation. Backendless services.

Magento 2 is an insane examples of code obfuscation potentially usable for obscuring malicious PHP code!

There you can read how to attache EFS as persistent storage for Magento lambda functions!

There You can read how to install legacy Magento 2 PHP monolith inside of lambda function:

https://link.medium.com/ouw6KwLMw9

Written by

Magento/APP Cloud Architect. Melting metal server infrastructure into cloud solutions.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store