I was trying to deploy my Laravel application to AWS Lambda using Bref. I tried to exclude almost all the images, videos and still I am getting
Serverless Error ----------------------------------------
An error occurred: ArtisanLambdaFunction - Resource handler returned message: "Unzipped size must be smaller than 235311048 bytes (Service: Lambda, Status Code: 400 ...
My serverless.yml file is
service: my-laravel-application
provider:
name: aws
# The AWS region in which to deploy (us-east-1 is the default)
region: eu-west-1
# The stage of the application, e.g. dev, production, staging… ('dev' is the default)
stage: dev
runtime: provided.al2
package:
individually: true
# Directories to exclude from deployment
exclude:
- node_modules/**
- public/storage/**
- resources/assets/**
- storage/**
- tests/**
- public/images/**
- public/uploads/**
- public/videos/**
functions:
# This function runs the Laravel website/API
web:
handler: public/index.php
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
layers:
- ${bref:layer.php-74-fpm}
events:
- httpApi: '*'
# This function lets us run artisan commands in Lambda
artisan:
handler: artisan
timeout: 120 # in seconds
layers:
- ${bref:layer.php-74} # PHP
- ${bref:layer.console} # The "console" layer
plugins:
# We need to include the Bref plugin
- ./vendor/bref/bref
I tried to exclude almost all the assets from zip. Still, I am getting the same error. While zipping, the total size of my application is 119.4 MB only.
I could fix this issue by adding all public assets to exclude list and hence reduced the size of zip file to 43 MB.
While extracting the zip, the total size of unzipped is less than 220606645 bytes
Then ,