When creating the lambda function through Amplify CLI, there are 4 function templates provided:
I am confused about the usage of "Hello World" and "Serverless ExpressJS function". Let's say I want to implement a lambda function that contains custom query to get the result from Dynamodb, which template is suitable, or is the best practice to use?
It all helps you start the project with boilerplate code.
For your use case, you can use CRUD Function for DynamoDB. This will create a DynamoDB table and Integrate it with API Gateway and generate boilerplate code for your chosen programming language. You can change the CRUD operations to more custom - changing the parameter.
API Gateway directs all requests to your Express API, so it's up to your route handling, so you can change them later.
As your NodeJS app grows, you might need to organize your routes and use express.Router
to make it modular.
It's a simple boilerplate code that returns a string. You can use this for simple tasks or private API calls.
You can run any lambda function when a certain event happens. For example you can execute a lambda function if you configured a lambda trigger for the DynamoDB event.
It's not integrated with DynamoDB, this option will generate simple Express endpoints like GET/, POST/, PUT/, DELETE/
I'd recommend you to try out all these options and see how it works.