We have had custom layers for a long time in Lambda, I have used them for a few mini app I have personally as well as professionally. Then along comes this official AWS Post on the (L)ambda(A)piGateway(M)ySQL(P)hp stack.
I host a few Wordpress sites one of which is DevCOP on LightSail. LightSail has served me incredibly well however it would be an interesting challenge to move the site to Lambda and Serverless Aurora.
But first things first how can we create an deploy a PHP layer and some sample PHP code to run in lambda without using one of the pre-built packages and why would you want to do this. I suspect the main reason you might want to do this yourself is to well….do it yourself. It helps to understand what is happening and how the pieces come together.
We are going to use this instance to compile source code, it will compile just fine with the smaller instance however it will take a little longer, as I will terminate this environment after this experiment I will use the biggest/fastest as it will only be active for less than 1 hour. Ensure “Amazon Linux” is selected in platform.