0👍
✅
was solved by installing the serverless-lift plugin
serverless plugin install -n serverless-lift
as mentioned in the ‘bref’ Documents then compiling the assets before deploying as
npm run prod
then
serverless deploy
and now the new serverless.yml file looks like that
service: serverless-test
provider:
name: aws
# The AWS region in which to deploy (us-east-1 is the default)
region: us-east-1
# The stage of the application, e.g. dev, production, staging… ('dev' is the default)
stage: dev
runtime: provided.al2
environment:
# environment variable for Laravel
FILESYSTEM_DISK: s3
AWS_BUCKET: !Ref Storage
APP_ENV: 'dev'
# APP_DEBUG: false
iam:
role:
statements:
# Allow Lambda to read and write files in the S3 buckets
- Effect: Allow
Action: s3:*
Resource:
- !Sub '${Storage.Arn}' # the storage bucket
- !Sub '${Storage.Arn}/*' # and everything inside
package:
# Directories to exclude from deployment
patterns:
- '!node_modules/**'
- '!public/storage'
- '!resources/assets/**'
- '!storage/**'
- '!tests/**'
custom:
lift:
assets:
path: public
url: /
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-80-fpm}
events:
- httpApi: '*'
# This function lets us run artisan commands in Lambda
artisan:
handler: artisan
timeout: 120 # in seconds
layers:
- ${bref:layer.php-80} # PHP
- ${bref:layer.console} # The "console" layer
plugins:
# We need to include the Bref plugin
- ./vendor/bref/bref
- serverless-lift
constructs:
website:
type: server-side-website
assets:
'/css/*': public/css
'/js/*': public/js
'/images/*': public/images
# add here any file or directory that needs to be served from S3
resources:
Resources:
# Create our S3 storage bucket using CloudFormation
Storage:
Type: AWS::S3::Bucket
Source:stackexchange.com