From df5c05adcdd8905c86e63888cb894cdae4627a39 Mon Sep 17 00:00:00 2001 From: Aran Reeks <3313791+aran112000@users.noreply.github.com> Date: Mon, 20 Mar 2023 20:20:56 +0000 Subject: [PATCH 1/3] Moved to example dir --- examples/ququed/serverless.yml | 107 +++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 examples/ququed/serverless.yml diff --git a/examples/ququed/serverless.yml b/examples/ququed/serverless.yml new file mode 100644 index 0000000..eda3ee8 --- /dev/null +++ b/examples/ququed/serverless.yml @@ -0,0 +1,107 @@ +# This config skeleton deploys a solid foundation for your Serverless Laravel applications. +# Install the required Serverless plugins: +# - serverless plugin install -n serverless-lift +# - serverless plugin install -n serverless-scriptable-plugin + +service: laravel + +params: + default: + domain: dev.example.com # TODO: Your staging/dev domain + amazon_ssl_arn: arn:aws:acm:us-east-1:xxxxxxxxx:certificate/xxxx-xxxx-xxxx # TODO: issue SSL within us-east-1 - Instructions: https://bref.sh/docs/websites.html#setting-up-a-domain-name + laravel_env: staging + laravel_debug: false # If you require your debug view change this, but be VERY careful not to leak any secrets! + tags: # Tag all of our resources - Useful for cost analysis using + project_name: ${self:service} + stage: ${opt:stage, self:provider.stage} + prod: + domain: prod.example.com # TODO: Your prod domain + amazon_ssl_arn: arn:aws:acm:us-east-1:xxxxxxxxx:certificate/xxxx-xxxx-xxxx # TODO: issue SSL within us-east-1 - Instructions: https://bref.sh/docs/websites.html#setting-up-a-domain-name + laravel_env: production + +provider: + name: aws + region: us-east-1 # The AWS region in which to deploy (us-east-1 is the default) + logRetentionInDays: 30 + stackTags: ${param:tags} + tags: ${param:tags} + environment: # Add any environment variables for your Lambda environment here + APP_URL: https://${param:domain} + APP_ENV: ${param:laravel_env} + APP_DEBUG: ${param:laravel_debug} + MAINTENANCE_MODE: ${param:maintenance, null} + QUEUE_CONNECTION: sqs + SQS_QUEUE: ${construct:laravel-default-queue.queueUrl} + +functions: + # This function runs the Laravel website/API using PHP-FPM + # If you wish to use Laravel Octane, please comment this function, and replace with the commented one below: + web: + handler: public/index.php + runtime: php-82-fpm + timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds) + events: + - httpApi: '*' + + # This function runs the Laravel website/API using Laravel Octane + # If you wish to use Laravel without Octane, please comment this function, and replace with the one above: + #web: + # handler: Bref\LaravelBridge\Http\OctaneHandler + # environment: + # BREF_LOOP_MAX: 250 + # OCTANE_PERSIST_DATABASE_SESSIONS: 1 + # runtime: php-82 + # timeout: 28 # in seconds + # events: + # - httpApi: '*' + + # This function lets us run Artisan commands within the Lambda environment + # To use: instead of `php artisan db:seed` you'd run from your local env to seed your Lambda environment: + # serverless bref:cli --args="db:seed" + artisan: + handler: artisan + runtime: php-82-console + timeout: 720 # in seconds + events: + - schedule: # We also schedule this function to run the scheduler every minute to match Laravel's crons + rate: rate(1 minute) + input: '"schedule:run"' + +constructs: + laravel-default-queue: + type: queue + maxRetries: 1 + worker: + handler: Bref\LaravelBridge\Queue\QueueHandler + timeout: 720 + runtime: php-82 + + website: + type: server-side-website + domain: ${param:domain} + certificate: ${param:amazon_ssl_arn} + assets: + '/vendor/*': public/vendor + '/build/assets/*': public/build/assets + '/images/*': public/images + '/favicon.ico': public/favicon.ico + '/robots.txt': public/robots.txt + +custom: + scriptable: + hooks: + after:deploy:deploy: + - serverless bref:cli --stage=${sls:stage} --args="migrate --force" # Run any new migrations on deployment + +plugins: + - ./vendor/bref/bref + - serverless-lift + - serverless-scriptable-plugin + +package: + patterns: # Files and directories to exclude from deployment + - '!node_modules/**' + - '!public/storage' + - '!resources/assets/**' + - '!storage/**' + - '!tests/**' From 2482c85c88d86367444a2062f8c671ffd9fd542b Mon Sep 17 00:00:00 2001 From: Aran Reeks <3313791+aran112000@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:39:44 +0100 Subject: [PATCH 2/3] Fix typo in directory name --- examples/{ququed => queued}/serverless.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{ququed => queued}/serverless.yml (100%) diff --git a/examples/ququed/serverless.yml b/examples/queued/serverless.yml similarity index 100% rename from examples/ququed/serverless.yml rename to examples/queued/serverless.yml From 0b93c8f4499ddf6e1993d486a6747a50ed384dd2 Mon Sep 17 00:00:00 2001 From: Aran Reeks <3313791+aran112000@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:46:31 +0100 Subject: [PATCH 3/3] Move documentation into its own file within the example dir --- examples/queued/README.md | 17 +++++++++++++++++ examples/queued/serverless.yml | 5 ----- 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 examples/queued/README.md diff --git a/examples/queued/README.md b/examples/queued/README.md new file mode 100644 index 0000000..f0df594 --- /dev/null +++ b/examples/queued/README.md @@ -0,0 +1,17 @@ +# Queued Laravel using Lift constructs + +This config skeleton deploys a solid foundation for your Serverless Laravel applications using https://github.com/getlift/lift for the SQS queue construct. + +## Required plugins: +Install the required Serverless plugins (Lift and Scriptable): + - serverless plugin install -n serverless-lift + - serverless plugin install -n serverless-scriptable-plugin + +Lift give us easy access to AWS CDK constructs that help us build out best practice components (in this example, our SQS queue). If you want to learn more about Lift, check out their documentation here: +https://www.serverless.com/plugins/lift + +The Scritable plugin provides us with deployment hooks to help ensure we run any pending Laravel Migrations at the point of deployment. Documentation can be found here: +https://www.serverless.com/plugins/serverless-scriptable-plugin + +## Laravel Octane support (Optional) +Simply swap the commented blocks in the example serverless.yml file provided to start using Laravel Octane \ No newline at end of file diff --git a/examples/queued/serverless.yml b/examples/queued/serverless.yml index eda3ee8..40811d4 100644 --- a/examples/queued/serverless.yml +++ b/examples/queued/serverless.yml @@ -1,8 +1,3 @@ -# This config skeleton deploys a solid foundation for your Serverless Laravel applications. -# Install the required Serverless plugins: -# - serverless plugin install -n serverless-lift -# - serverless plugin install -n serverless-scriptable-plugin - service: laravel params: