Skip to content

Commit

Permalink
Merge branch 'feature/update-lambda-runtimes' into feature/make-funct…
Browse files Browse the repository at this point in the history
…ion-command
  • Loading branch information
wilsenhc committed Nov 10, 2023
2 parents 80d4157 + 61b4c6e commit 960724b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Sidecar packages, creates, deploys, and executes Lambda functions from your Lara

You can write functions in any of the following runtimes and execute them straight from PHP:

- Node.js 20
- Node.js 18
- Node.js 16
- Node.js 14
Expand Down
1 change: 1 addition & 0 deletions docs/functions/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The only two things _required_ for a Sidecar function are the [package and the h

Lambda supports multiple languages through the use of runtimes. You can choose any of the following runtimes by returning its corresponding identifier:

- Node.js 20: `nodejs20.x`
- Node.js 18: `nodejs18.x`
- Node.js 16: `nodejs16.x`
- Node.js 14: `nodejs14.x`
Expand Down
22 changes: 9 additions & 13 deletions docs/functions/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ When you run that, you'll see an output log similar to the one below:
↳ Activating Version 1 of SC-Laravel-local-Sidecar-OgImage.
```

The deployment process consists of
The deployment process consists of
- zipping the handler code
- uploading the zip file to S3
- creating the Lambda function if it doesn't exist
Expand All @@ -37,7 +37,7 @@ There are two required steps in order to make your functions live and usable.

Because your handler code may require you to `npm install`, `bundle install`, or something similar, you may be building and deploying your handler code in CI or from your local computer.

Once that handler code is all bundled and deployed to Lambda, there may be a secondary step required to deploy your main application.
Once that handler code is all bundled and deployed to Lambda, there may be a secondary step required to deploy your main application.

During this secondary step, your Lambda functions are going to be updated but your application code will not be, which could lead to errors for your users.

Expand Down Expand Up @@ -75,15 +75,15 @@ environments:
- 'php artisan sidecar:deploy --env=production' # [tl! ~~]
deploy: # [tl! ~~]
- 'php artisan sidecar:activate' # [tl! ~~]
```
```
Your functions would be built and deployed on whatever machine is handling the Vapor deploy process, and then would be activated as Vapor activates your newest application code.
> Note that in this example we're setting the environment to "production" in the build, because it's likely that your "build" step is running in an environment that doesn't have it's ENV set to "production." See below for more details.
## Faking the Environment
Sidecar names your function based on environment, to prevent collisions between local, staging, production, etc. This could pose a problem if you are deploying your production functions from your build or CI server.
Sidecar names your function based on environment, to prevent collisions between local, staging, production, etc. This could pose a problem if you are deploying your production functions from your build or CI server.
If you need to deploy an environment other than the one you are in, you can override the environment from the config by passing an `--env` flag to the Deploy and Activate commands.

Expand All @@ -96,7 +96,7 @@ To read more about environments, head to the [Environments section](../environme

## Setting Environment Variables

This is covered in the [Environment Variables](customization#environment-variables) section of the Customization docs, but we'll cover strategies around env vars and deployment here.
This is covered in the [Environment Variables](customization#environment-variables) section of the Customization docs, but we'll cover strategies around env vars and deployment here.

Some of your functions will require environment variables, either from your Laravel application or something completely distinct. In some cases, you may need to set a static variable so that some library will work [(LibreOffice example)](https://github.com/hammerstonedev/sidecar/issues/24):

Expand Down Expand Up @@ -159,7 +159,7 @@ Sidecar sets the environment variables _upon activation_. If you are deploying f

Environment variables are set before activation, and before any pre-warming takes place.

And remember! If Sidecar manages the environment variables for a function, it will clobber any changes you make in the AWS UI, so you cannot use both methods simultaneously.
And remember! If Sidecar manages the environment variables for a function, it will clobber any changes you make in the AWS UI, so you cannot use both methods simultaneously.

## Reusing Package Files

Expand All @@ -172,15 +172,11 @@ In the event that neither the code nor function configuration have changed, Side
You will see output similar to the following:

```text
[Sidecar] Deploying App\Sidecar\OgImage to Lambda. (Runtime nodejs18.x.)
[Sidecar] Deploying App\Sidecar\OgImage to Lambda. (Runtime nodejs20.x.)
↳ Function already exists, potentially updating code and configuration.
↳ Packaging function code.
↳ Package unchanged, reusing previous code package at s3://sidecar-us-east-2-XXX/sidecar/001-79a5915eaec296be04a0f4fb7cc80e40.zip.
↳ Function code and configuration are unchanged! Not updating anything. [tl! focus]
[Sidecar] Activating function App\Sidecar\OgImage.
↳ Activating Version 1 of SC-Laravel-local-Sidecar-OgImage.
```




```
4 changes: 2 additions & 2 deletions docs/functions/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The following four methods are available to you on every Sidecar function:
- `beforeActivation`
- `afterActivation`

## Example: Before Deployment
## Example: Before Deployment

The `beforeDeployment` hook is a great place to run a build step if your function requires it. We'll be using the `ncc build` command mentioned in the [Handlers & Packages](handlers-and-packages#compiling-your-handler-with-ncc) section for this example.

Expand Down Expand Up @@ -44,7 +44,7 @@ With this in place, you'll see something like this in your logs:
```text
[Sidecar] Deploying App\Sidecar\Example to Lambda as `SC-App-local-Sidecar-Example`.
↳ Environment: local
↳ Runtime: nodejs18.x
↳ Runtime: nodejs20.x
↳ Compiling bundle with NCC. [tl! focus]
↳ Running `ncc build resources/lambda/image.js -o resources/lambda/dist` [tl! focus]
↳ Bundle compiled! [tl! focus]
Expand Down
1 change: 1 addition & 0 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ It works with _any_ Laravel 7, 8, 9 or 10 application, hosted _anywhere_, includ

You can write functions in any of the following runtimes and execute them straight from PHP:

- Node.js 20
- Node.js 18
- Node.js 16
- Node.js 14
Expand Down
2 changes: 1 addition & 1 deletion src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class Manager
{
use Macroable, HandlesLogging, ManagesEnvironments;
use HandlesLogging, Macroable, ManagesEnvironments;

/**
* @var string
Expand Down
2 changes: 2 additions & 0 deletions src/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

abstract class Runtime
{
public const NODEJS_20 = 'nodejs20.x';

public const NODEJS_18 = 'nodejs18.x';

public const NODEJS_16 = 'nodejs16.x';
Expand Down

0 comments on commit 960724b

Please sign in to comment.