AWS Lambda & Symfony Bref - Deploying Symfony 4 website

386 Views Asked by At

I would like deploy my Symfony 4 website thanks to AWS Lambda and Symfony Bref, I followed this docs :

but I have this error :

enter image description here

My serverless.yaml file :

service: bref-symfony

package:
    exclude:
        - node_modules/**
        - venv/**

provider:
    name: aws
    region: eu-west-3
    runtime: provided
    environment:
        # Symfony environment variables
        APP_ENV: prod

plugins:
    - ./vendor/bref/bref

functions:
    website:
        handler: public/index.php
        timeout: 30 # in seconds (API Gateway has a timeout of 30 seconds)
        layers:
            - ${bref:layer.php-73-fpm}
        events:
            -   http: 'ANY /'
            -   http: 'ANY /{proxy+}'
    console:
        handler: bin/console
        timeout: 120 # in seconds
        layers:
            - ${bref:layer.php-73} # PHP
            - ${bref:layer.console} # The "console" layer

What is the problem please ?

1

There are 1 best solutions below

0
On

It looks like you need to cut back on what is included in your app image. Make sure you are running prod-only dependencies on composer:

composer inst --no-dev -o

You also can add something like this to your serverless.yaml to only include the files you need to run your Symfony app:

package:
    exclude:
        - '*'
        - '**'
    include:
        - 'bin/**'
        - 'config/**'
        - 'public/index.php'
        - 'src/**'
        - 'var/cache/prod/**'
        - 'translations/**'
        - 'vendor/**'
        - '.env'