This repository serves as a Mono Repo for managing all Amplify Lambda functions. It is part of a larger deployment for Amplify GenAI which can be found at https://github.com/gaiin-platform.
Initial setup requires the creation of a /var
directory at the root level of the repository. The environment-specific variables should be placed in the following files within the /var
directory:
dev-var.yml
for Developer environment variablesstaging-var.yml
for Staging environment variablesprod-var.yml
for Production environment variables
Variables should be configured inside your amplify-genai-backend/<environment>/<environment>-var.yml
file. Comments are provided in dev-var.yml-example
for each variable.
To deploy a service directly from the root of the repository, use the command structure below, replacing service-name
with your specific service name and stage
with the appropriate deployment stage ('dev', 'staging', 'prod'):
serverless service-name:deploy --stage <stage>
serverless amplify-lambda:deploy --stage dev
Because we are using serverless-compose to import variables across services, you have to deploy from the root of the repo or you could have issues resolving variables within the application
- Navigate to each cloned directory and install the Node.js dependencies:
cd amplify-genai-backend
npm i
cd ../amplify
npm i
To run lambda-js
with localServer.js
:
- Navigate to the
amplify-lambda-js
directory:
cd amplify-lambda-js/
- Install the dependencies if you haven't already:
npm i
-
Ensure AWS credentials are located in ~/.aws/credentials and AWS_PROFILE env var matches
-
Run the local server from root:
node amplify-lambda-js/local/localServer.js
First, install Serverless globally:
npm install -g serverless
Then, install the necessary Serverless plugins:
npm install --save-dev @serverless/compose
npm install --save-dev serverless-offline
sls plugin install -n serverless-python-requirements
After navigating to the amplify-lambda
directory, install any additional dependencies:
npm i
You can run Serverless offline for amplify-lambda
using one of the following methods,
where corresponds to the appropriate deployment stage ('dev', 'staging', 'prod'):
Serverless offline does not support Serverless Compose. Because of this limitation, the only way to run serverless offline is to
- By navigating to the
amplify-lambda
directory:
cd amplify-lambda
serverless offline --httpPort 3015 --stage <stage>
To have Amplify running and pointed to your local lambda versions, follow these steps:
- Add the necessary variables to your
.env.local
file:
API_BASE_URL=http://localhost:3015
CHAT_ENDPOINT=http://localhost:8000
- Start the development server:
npm run dev
- Open http://localhost:3000 in your browser to view the application.