Runtime - Concepts
Conceptually, Lambda Genie has 2 independent parts.
- The Lambda Genie Console that allows you to define your business entities, rules, feature flags, and configuration values.
- The Lambda Genie Runtime that is a Node.js module that you can add to your AWS Lambda, Node.js or Web(JavaScript/TypeScript) project to execute the rules, feature flags, and configuration values.
Lambda Genie Runtime
In the previous step, you learned how to use the Lambda Genie Console to define your business entities, rules, feature flags, and configuration values. The final step of this process was to get the config file out of the console. The runtime needs this config file to execute the rules, feature flags, and configuration values. However, the whole point of Lambda Genie is to get your configuration into your application without having to redeploy. So, how do you get the config file into your application? Well, this is where you have a lot of flexibility.
Lambda Genie Runtime - Config API
The Lambda Genie Runtime provides a simple API that allows you to get the config file. When you initialize the runtime, you pass in a callback function that is called when the config file is needed. What you do in this callback function is up to you. You can get the config file from a file, from an API, a database or from AWS S3. The Lambda Genie Runtime does not care where you get the config file from. It just needs to be a JSON file. It will call this loadConfig method at an interval you can customize, and it will cache the config file in memory. There are multiple examples of this we will walk through in the next couples sections, so fear not if this is a bit abstract.
Environment Management
Lambda Genie is built around the concept of environments, so it allows you to have different configuration values for each environment. For example, you may want to have a different feature flag value for development than you do for production. You can define these environment specific values in the Lambda Genie Console. Same applies for the rules engine, as well as the predefined lists.
The Lambda Genie config file is essentially a JSON file that contains all the rules, feature flags, and configuration values you defined in the Lambda Genie Console. By default we make a predefined list of environments with values dev, test, and prod. When you export the config file, you have the option to export a single config file for all environments, or to export config files per environment. In the previous step, you setup environment specific values for certain items. If you exported a single config file, you should see the environment specific values in the config file. If you exported a config file per environment, you should see a config file for each environment with the global values and the environment specific values for that environment.