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 variablesVariables 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
cd amplify-genai-backend
npm i
cd ../amplify
npm i
lambda-js
LocallyTo run lambda-js
with localServer.js
:
amplify-lambda-js
directory:cd amplify-lambda-js/
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
serverless amplify-lambda:offline --httpPort 3015 --stage <stage>
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:
.env.local
file:API_BASE_URL=http://localhost:3015
CHAT_ENDPOINT=http://localhost:8000
npm run dev