Serverless application development has never been easier. With the introduction of the Sigma IDE by SLAppForge, Serverless application now takes much less time. The post intends to explain the full development process of a lambda function using the Sigma IDE and by the end, you will understand the advanced functionality provided by the IDE.
Need to view a demo?
Slappbooks is an accounting application developed using the Sigma IDE. A live demo of Slappbooks is available at https://slappbooks.slappforge.com/
Need to Deploy the Serverless sample using Sigma?
Need to develop the application step by step?
To begin development, you’ll need to create an account with SLAppForge and provide your AWS credentials. You will be shown the following page upon successful login.
As you can see a lambda file is already open. Let’s first look at a simple lambda function that would store a transaction in an RDS database. The database schema can be obtained from the following code snippet.
Navigate to projects pane and you will be displayed the following page.
You could rename your first lambda file to
add-transaction.js. Just right click on the file and select rename. Again navigate to the Resources pane.
The first step is to deploy an API gateway that would listen to user requests. Traditionally, this required navigating to AWS API gateway and configuring properties. Now, you can achieve this by a simple drag and drop. From the Resources pane, drag API Gateway icon onto the event of the lambda function. Since we’re trying to trigger an event, this makes sense. right?
Since we’re developing a new API, enter the API name. Keep Edge optimized as the default option and add your resource path. For the
add-transaction lambda we can use the resource path `/addTransaction`. Select the method as
POST. Finally select your deployment stage and click the inject button.
With just a few clicks, we have configured an AWS API gateway.
Next, we need to configure an RDS instance. Again click on
RDS from the Resources pane and drag and drop to the function body. Since we are trying to develop a logic using RDS, it makes more sense to add it to the function body. Right? The following prompt would be displayed afterwards.
Select the RDS Engine as
MySQL. Select the DB Engine version and DB Instance class and add the instance identifier as
slappbooksdb. Master Username as
slappbooksuser and enter a password. Enter the database name as
slappbooksdb. Database port
3306. Paste the DB initialization query from the this link.
Afterwards, select the operation as
Begin Transaction since we’re trying to define a transactional block. Next, click on the inject button. Now you’re lambda function would look like the image given below.
Now, we need to inject a query block within the transactional block. Now add the code required to insert a transaction. You’ll need to define a query block as follows.
Enter your sql query required in the field
query and add the parameters that you need to insert into the query in the
For example you could use
let sql = 'INSERT INTO transaction (transaction_id, set_id, date, entity_id, is_credit, cheque_no, voucher_no, amount, notes, reconcile) VALUES (?,?,?,?,?, ?, ?, ?, ?, ?);' let transactionInsertArray = [transaction.trId, transaction.setId, transaction.date, entity_id, transaction.isCredit, transaction.checkNo, transaction.voucherNo, transaction.amount, transaction.notes, transaction.reconcile];
Now you can start focusing on your logic. The completed lambda function would appear as given below.
Follow the same steps in developing the other lambda functions and If you’d like to have a look at our code, please navigate to https://github.com/slappforge/slappbooks.
Slappbooks also has a reactjs based front-end application for viewing purposes. Please refer to https://github.com/slappforge/slappbooks-frontend if you’d like to deploy the front end as well.