I created aws lambda function based on laravel framework using bref. Link: https://bref.sh
this is my code to download using media library spartie
$mediaItem = Media::where('model_id',$id)->where('model_type','App\MODEL')->first();
return $mediaItem;
My configuration is
AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY=XXXXX+XXXXXXXX
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=my-bucket
When I download file locally all work perfectly, but when I try to download on s3 in lambda function I got error:
{ "message" : "Internal server error" }
I use this package aws:
league/flysystem-aws-s3-v3 ~1.0
my serverless.yaml
service: serverless-api
provider:
name: aws
region: eu-central-1
runtime: provided
environment:
APP_ENV: production
iamRoleStatements:
- Effect: Allow
Action:
- s3:*
Resource: 'arn:aws:s3:::bucket/*'
plugins:
- ./vendor/bref/bref
package:
exclude:
- node_modules/**
- public/storage
- storage/**
- tests/**
- .env
functions:
website:
handler: public/index.php
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
layers:
- arn:aws:lambda:eu-central-1:209497400698:layer:php-72-fpm:23
events:
- http: 'ANY /'
- http: 'ANY /{proxy+}'
artisan:
handler: artisan
timeout: 120 # in seconds
layers:
- arn:aws:lambda:eu-central-1:209497400698:layer:php-72:22
- arn:aws:lambda:eu-central-1:209497400698:layer:console:22
also i assign role for s3 , But I have no idea how it's the problem .
thank you .