Serverless Execution with InRule for JavaScript and AWS Lambda


Dan Reynolds


Serverless execution is gaining momentum. If you aren’t familiar with the concept, the idea is that you just provide the code you want to run and the platform magically makes it available as a service. It’s serverless, because you, the user, don’t have to provision a server in any way, shape or form. The best part, and the reason for its recent popularity, is that you only pay for the execution time, whereas traditionally you would have to pay for the server to be up and running. It is an elastic model that will immediately scale on-demand and you do not have to pay for the setup, teardown, or idle server time.

Amazon, Google, and Microsoft all have serverless cloud offerings. In this post I’ll demonstrate Amazon’s answer to serverless execution, AWS Lambda. A Lambda function is simply code, written in a handful of possible languages, that will execute when called as a service. It’s simple text in/text out. One of the supported languages is Node/JavaScript, which works extremely well with InRule® for JavaScript, our JavaScript rules engine. Throw in an extendible authoring tool and we’ve got ourselves an end-to-end solution!


The rules are authored in irAuthor, InRule’s rule authoring tool. I’ve also written my own custom extension that adds a button to the ribbon. When clicked, it will take the rules from irAuthor, send them to the InRule Distribution service (irDistribution) where the rules are converted into JavaScript. The custom extension then takes the JavaScript and updates the Lambda Function in AWS with the new rules. The final piece is an independent web page that I wrote to test the service in Amazon.

I’m using rules to calculate a mortgage for the demo, which are called from the test page. The page does a simple JavaScript POST to call the Lambda function. The results returned from the function are then written back to the page.

Demo Video


This type of solution is very flexible and affordable. The cost is based on what your business uses as opposed to paying for provisioned idle servers that sit unused. Serverless brings an unprecedented alignment between resource allocation and resource consumption; pair that with high speed caching technologies and the next generation of elastic compute is here.

A couple final notes:

InRule for JavaScript | inrule said: "[…] couple of weeks ago we announced availability of InRule® for JavaScript through an early adopter program. To our knowledge this is […]".
Dynamic Surveys in Dynamics CRM Part II: Managing Dependencies | inrule said: "[…] this post makes extensive references to my preceding post, Surveys in Dynamics CRM Part I: Don’t Be a Monkey With Your Survey. If you are the type of person who likes to get the full story, you should go back and read the […]".
Josh Elster said: "In the time since this post was published, I've added (via a PR) full Windows Containers example code, DOCKERFILEs and scripts. They share common ancestry with the GH Gists I posted earlier, but are more up-to-date and tested. Here's a direct link to that sub-folder: Now that our Samples repository is public, feel free to file Issues if you have problems or features you'd like to see implemented. If you have something you'd like to contribute, then by all means do so! The contributor guidelines and process are listed in the root of the repository. Enjoy! I'll update the body of the post as well with this link.".