Running sidecar lambdas locally #126
benmag
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First off just want to say, sidecar is awesome!
I wanted to quickly share how I am running sidecar/lambdas for my local development in case it's of use to anyone else in the future.
1. Install AWS SAM CLI
AWS SAM CLI lets us emulate AWS serverless functions right on our local machine. Install the AWS SAM CLI by following the instructions in the link below:
2. Create a SAM template.yaml
In your Lambda function folder (for instance,
/resources/lambda
), create atemplate.yaml
file. This file tells AWS SAM how to handle the Lambda function locally. Here's a simple example, you can add additional functions as required:3. Run Lambda Functions Locally
Now comes the exciting part! From within your /resources/lambda directory, run the following command to start your Lambda functions locally:
This command fires up the local Lambda environment, allowing you to test your functions without the need to deploy them to AWS or have an internet connection.
4. Configure a Custom Service Provider
To customize certain aspects of the Sidecar package specifically for local development, we'll need to override a few classes.
Create the following files in your app
Services/Sidecar/AwsClientConfiguration.php
Services/Sidecar/LambdaClient.php
We'll use a custom service provider to ensure these classes are used only during local development. Create the following file:
app/Providers/SidecarServiceProvider.php
5. Add the New Service Provider
Finally, make use of the custom service provider. Inside your
config/app.php
file, locate the 'providers' array, and add the following line:That's it!
Now you can run your Sidecar/Lambda functions locally!
Beta Was this translation helpful? Give feedback.
All reactions