How to Make a Rules Engine Using Python Rules

A serverless computing system can help your business stay agile. With a powerful computing engine, you can write code without the need for infrastructure or any servers. Here is how to do it.

Start with an Amazon S3 Bucket

You will need an AWS account to begin, and then you can go to the AWS Console and follow this link: https://s3.console.aws.amazon.com/s3/buckets

Next, click on “Create”, and fill out the form. Once you are finished, choose “Create Bucket” to complete this step.

Make a New Lambda Function

The next task is to make a Lamba Function that has a Zen Engine Layer on it. The layer is contained in a zip file that includes all the necessary dependencies. Go to the Lamba home page (https://console.aws.amazon.com/lambda/home#/layers) to get started with this step and create a layer. Choose your configurations on the form. The name is not important, but you will need to upload the following file from Amazon S3: https://gorules-public-eu-west-1.s3.eu-west-1.amazonaws.com/lambda/layers/python/python-zen_engine-v0.4.1-x86_64-linux-gnu.zip.

Choose runtime Python 3.9, and then select x86_64 architecture from there. Then choose a Function with the same configurations and attach the layer to the Function. To do this, choose Custom Layers and then pick the version you want. Click Add to complete this step.

Configure the Permissions

To set up the configurations, you can go to the Configuration tab and choose Edit from the Permission menu. Then, create a new role, which you can find in the Execution role area. You will need to input a new name and then choose read-only permissions from the Policy Template area. Once you save your file, it is good to go.

Create a Python Rules Engine

The final step is to write up some Python code, if you want to create a Python rules engine. You can find the source code for that through this link: https://github.com/gorules/zen/blob/master/examples/python-lambda-s3/lambda_function.py

If you followed all the steps correctly so far, you will be able to bring in a Zen library free of direct function dependency, and that’s thanks to the added Lambda layer.

You may also need to make a JDM file for your system, which can be done in the Editor. A template is already there for you to use, and that will help you to determine shipping costs for your business. This decision file can be downloaded directly to your S3 bucket.

From there, you can test the function simply by going over to the Lambda Function and choosing Test. Use that to look for your JDM (or JSON) file.

In Conclusion

Now you should know how to create an Amazon S3 bucket and attach a Zen Engine Layer to it. This process will make your deployment method much more streamlined. You should see your system process faster and operate with greater agility.

Log In

Forgot password?

Forgot password?

Enter your account data and we will send you a link to reset your password.

Your password reset link appears to be invalid or expired.

Log in

Privacy Policy

Add to Collection

No Collections

Here you'll find all collections you've created before.