For explaination follow my blog
https://github.com/ksingh7/laravel_custom_runtime_lambda.git
- Edit
build.shif you like to add a specific library to your Lambda Layer (optional) - Edit
regions.shif you like to add multiple AWS regions to make your Lambda Layer available to - Edit
create-buckets.shupload.shpublish.shandunpublish.shif you like to change the bucket name - Edit
php.iniif you like to enable PHP extentions of your choice (Make sure you have installed them usingbuild.sh)
- Execute
maketo generatephp71.zipinpwd. This is your Lambda Custom Layer file - Execute
create-buckets.shto create bucket before uploading Lambda Layer to S3 - Execute
upload.shto upload Lambda Layer to S3 - Execute
publish.shto publish your custome Lambda Layer - Optionally you can also make your Lambda Layer publicly available by editing necessary section from
publish.sh - Once Lambda layer is published to AWS Lambda, login to Lambda console > Layers and grab the Layer ARN
- Edit
template.yamland update Lambda Layer ARN
aws s3 mb s3://lambda-php-laravel-layer-us-east-1 \
--region us-east-1 \
--profile ksingh-lambda-v2
sam package \
--template-file template.yaml \
--output-template-file output/serverless-laravel.yaml \
--s3-bucket lambda-php-laravel-layer-us-east-1 \
--profile ksingh-lambda-v2
sam deploy \
--template-file output/serverless-laravel.yaml \
--stack-name serverless-laravel \
--capabilities CAPABILITY_IAM \
--profile ksingh-lambda-v2
aws cloudformation delete-stack \
--stack-name serverless-laravel \
--profile ksingh-lambda-v2
aws s3 rb --force s3://lambda-php-laravel-layer-us-east-1 \
--profile ksingh-lambda-v2