gaiin-platform / amplify-genai-backend

MIT License
15 stars 10 forks source link

Cannot run amplify-lambda offline using instructions in Readme #23

Open alihacks opened 2 months ago

alihacks commented 2 months ago

I have tried this on a Windows and a Linux machine, and have gotten the same results. I have followed all the steps in the Readme.md and get the same results.

At steps under "Run Serverless Offline" Trying option 1, in the repo root:

$ serverless amplify-lambda:offline --httpPort 3015 --stage dev

Result is:

The command "amplify-lambda:offline" is not currently supported by Compose.

However, running serverless amplify-lamba offline ... seems to go further, maybe the : needs to be removed from the instructions?

Trying option 2, in the amplify-lambda directory

serverless offline --httpPort 3015 --stage dev

Result is:

Cannot resolve '${param:SHARE_ASSISTANTS_ENDPOINT}' variable at 'provider.environment.SHARE_ASSISTANTS_ENDPOINT'. No value is available for this variable, and no default value was provided. Please check your variable definitions or provide a default value.
Error: Cannot resolve '${param:SHARE_ASSISTANTS_ENDPOINT}' variable at 'provider.environment.SHARE_ASSISTANTS_ENDPOINT'. No value is available for this variable, and no default value was provided. Please check your variable definitions or provide a default value.

I have no experience using serverless but this may be because this parameter is defined in serverless-compose in the parent directory.

karnsab commented 2 months ago

Thanks, you are correct. I will work on updating the documentation. The serverless compose plugin is not compatible with serverless-offline. There's a few options out there to dynamically set them from a stagevar file or .env. But it would require some re-working of the serverless.yml to support it. Alternatively, you can manually drop those variables in there for testing and revert to deploy. I understand it's not ideal. I had to choose between making the deployment easier, or running serverless offline. If you see a way to improve that, please let me know. Happy to make changes.

alihacks commented 2 months ago

Allen, Thanks for your response. I see your point, my recommendation would be to update the documentation and pass this param at runtime when running offline such as: serverless offline --httpPort 3015 --stage dev --param="SHARE_ASSISTANTS_ENDPOINT=myval"

By the way - the next issue is this: "The Serverless version (4.3.3) does not satisfy the "frameworkVersion" (3) in serverless.yml" - this is likely because the instructions do not specify a version to install and I happened to get the latest. An easy solution to this is to not recommend installing globally, and running it from the package directory. This ensures control over versioning using package.json - even if it's already globally installed. The version installed in node_modules as a result of npm i is 3.39. So that command would be:

npx serverless offline --httpPort 3015 --stage dev --param="SHARE_ASSISTANTS_ENDPOINT=myval"