Skip to content

Commit

Permalink
Merge pull request #123 from wilsenhc/feature/update-lambda-runtimes
Browse files Browse the repository at this point in the history
Update supported Runtimes
  • Loading branch information
aarondfrancis authored Jan 10, 2024
2 parents 5d1e03b + 76f55ac commit 005009a
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 52 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ 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
- Node.js 12
- Node.js 10
- Python 3.12
- Python 3.11
- Python 3.10
- Python 3.9
- Python 3.8
- Python 3.7
- Python 3.6
- Python 2.7
- Ruby 2.7
- Ruby 2.5
- Java 21
- Java 17
- Java 11
- Java 8
- Go 1.x
- .NET 7
- .NET 6
- .NET Core 3.1
- .NET Core 2.1
- Ruby 3.2
- OS-only runtime (Amazon Linux 2023)
- OS-only runtime (Amazon Linux 2)

Any runtime that [Lambda supports](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html), you can use!

Expand Down
30 changes: 16 additions & 14 deletions docs/functions/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,32 @@ 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`
- Node.js 12: `nodejs12.x`
- Node.js 10: `nodejs10.x`
- Python 3.12: `python3.12`
- Python 3.11: `python3.11`
- Python 3.10: `python3.10`
- Python 3.9: `python3.9`
- Python 3.8: `python3.8`
- Python 3.7: `python3.7`
- Python 3.6: `python3.6`
- Python 2.7: `python2.7`
- Ruby 2.7: `ruby2.7`
- Ruby 2.5: `ruby2.5`
- Java 21: `java21`
- Java 17: `java17`
- Java 11: `java11`
- Java 8: `java8`
- Go 1.x: `go1.x`
- .NET Core 3.1: `dotnetcore3.1`
- .NET Core 2.1: `dotnetcore2.1`
- Java 8: `java8.al2`
- .NET 7: `dotnet7`
- .NET 6: `dotnet6`
- Ruby 3.2: `ruby3.2`
- OS-only runtime (Amazon Linux 2023): `provided.al2023`
- OS-only runtime (Amazon Linux 2): `provided.al2`

E.g. to use the Go runtime, you would return `go1.x`:
E.g. to use the Python 3.12 runtime, you would return `python3.12`:

```php
class ExampleFunction extends LambdaFunction
{
public function runtime() // [tl! focus:3]
{
return 'go1.x';
return 'python3.12';
}
}
```
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 nodejs12.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: nodejs14.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
19 changes: 13 additions & 6 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ 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
- Node.js 12
- Python 3.12
- Python 3.11
- Python 3.10
- Python 3.9
- Python 3.8
- Python 3.7
- Ruby 2.7
- Java 21
- Java 17
- Java 11
- Java 8
- Go 1.x
- .NET Core 3.1
- .NET 7
- .NET 6
- Ruby 3.2
- OS-only runtime (Amazon Linux 2023)
- OS-only runtime (Amazon Linux 2)

Any runtime that [Lambda supports](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html), you can use!

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/NoFunctionsRegisteredException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class NoFunctionsRegisteredException extends SidecarException
{
public function __construct($message = '', $code = 0, Throwable $previous = null)
public function __construct($message = '', $code = 0, ?Throwable $previous = null)
{
$message = "No Sidecar functions have been configured. \n" .
"Please check your config/sidecar.php file to ensure you have registered your functions. \n" .
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
32 changes: 28 additions & 4 deletions src/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,55 @@

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

public const NODEJS_18 = 'nodejs18.x';

public const NODEJS_16 = 'nodejs16.x';

/** @deprecated */
public const NODEJS_14 = 'nodejs14.x';

public const NODEJS_12 = 'nodejs12.x';
public const PYTHON_312 = 'python3.12';

public const PYTHON_311 = 'python3.11';

public const PYTHON_310 = 'python3.10';

public const PYTHON_39 = 'python3.9';

public const PYTHON_38 = 'python3.8';

/** @deprecated */
public const PYTHON_37 = 'python3.7';

public const RUBY_27 = 'ruby2.7';
public const JAVA_21 = 'java21';

public const JAVA_17 = 'java17';

public const JAVA_11 = 'java11';

public const JAVA_8_LINUX2 = 'java8.al2';

/** @deprecated */
public const JAVA_8 = 'java8';

public const GO_1X = 'go1.x';
public const DOT_NET_7 = 'dotnet7';

public const DOT_NET_6 = 'dotnet6';

public const DOT_NET_31 = 'dotnetcore3.1';
public const RUBY_32 = 'ruby3.2';

/** @deprecated */
public const RUBY_27 = 'ruby2.7';

/** @deprecated */
public const GO_1X = 'go1.x';

public const PROVIDED_AL2023 = 'provided.al2023';

public const PROVIDED_AL2 = 'provided.al2';

/** @deprecated */
public const PROVIDED = 'provided';
}

0 comments on commit 005009a

Please sign in to comment.