Skip to content

Commit

Permalink
adding bref to automate lambda deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
2amjsouza committed Dec 20, 2023
1 parent 4d62dc9 commit 7040381
Show file tree
Hide file tree
Showing 8 changed files with 15,341 additions and 212 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ yarn-error.log
/.idea
/.vscode
/xdebug
/.serverless/
/dump.rdb
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,53 @@ but it's extremely recommended to use [Supervisor](http://supervisord.org/) when

Laravel has a nice guide to properly [configure](https://laravel.com/docs/10.x/queues#supervisor-configuration) the Supervisor.

## Serverless deployment to AWS Lambda

This project uses [Bref](https://bref.sh/) framework to empower a smoothly deployment to
AWS Lambda.

It has a tiny list of dependencies to achieve that:

- Node.js 14.0+
- [Serverless](https://www.serverless.com/framework/docs) framework
- and, an AWS account (key and secret).

To install the Serverless framework:

```bash
$ npm install -g serverless
```

Install Serverless plugin dependency:
```bash
$ npm install
```

And them, setup the AWS credentials for the Serverless framework:
```bash
$ serverless config credentials --provider aws --key "key" --secret "secret"
```

You can change the project name on file `serverless.yml` to match your project name,
right on the first line:

```yml
service: laravel-mail-api
```
Last step before the actual deployment is to clear local cashed files:
```bash
$ php artisan config:clear
```

and, them:
```bash
$ serverless deploy
```

Once the process is finished, you will be prompted with the endpoint,
functions and jobs created on AWS Lambda!

## Contributing

Please, see [CONTRIBUTING](./contributing.md) for details.
Expand Down
1 change: 1 addition & 0 deletions app/Jobs/EmailDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function handle()
Mail::to($this->toEmail, $this->receiver)
->locale($this->getLanguage($this->language))
->send($this->message);
Log::info('Email sent');
}

/**
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"license": "MIT",
"require": {
"php": "^8.1",
"bref/bref": "^2.1",
"bref/laravel-bridge": "^2.2",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.0",
"laravel/sanctum": "^3.2",
Expand Down
Loading

0 comments on commit 7040381

Please sign in to comment.