Fanoni Bot Layers
Overview of Fanoni Bots
Fanoni Bots are functions that execute upon specific triggers. Think of them as AWS Lambda functions optimized for the Fanoni environment. They are written, deployed, and triggered via FHIR Subscriptions, streamlining various integrations in Fanoni.
Introduction to AWS Lambda Layers
Lambda Layers are .zip file archives that contain additional code or data, primarily used for library dependencies, custom runtimes, or configuration files. The reasons to use Lambda Layers are practical:
- Size Management: By moving function dependencies to a layer, deployment packages remain smaller.
- Code Organization: Layers allow for separation between core function logic and its dependencies. This means either can be updated independently.
- Dependency Sharing: Layers make it possible to set up dependencies once and use them across multiple functions.
- Utilizing Lambda Console Code Editor: For quick code edits, the editor is useful but has limitations with larger deployment packages. Layers can help mitigate this size issue.
How Fanoni Uses Lambda Layers
Fanoni's process for Lambda Layers is straightforward:
- Layer Creation: We take the predefined dependencies' pinned version, organize them into the required folder structure, and then upload to AWS.
- Publication: Bot Layers don't follow the typical Fanoni update cycle, which is post every Git commit. Instead, we update Bot Layers with our release versions, approximately once a week. This aligns with the update frequency of some dependencies in the NPM central repository.
A Note for Self-Hosters
If you're hosting Fanoni on your own infrastructure, remember that Bot layers don't auto-publish. To update the Bot Layer:
- Clone the Fanoni Repo (Note: You can clone the main Fanoni repo instead of creating a fork)
- Build the Project
- Deploy: Utilize
./scripts/deploy-bot-layer.shto deploy the new version.