Key/Value Stores

1. System Context

Developers use Nitric to define required key/value stores within their application.

  • App code uses the Key/Value resource from the Nitric SDK.
  • Developers define key/value stores their application requires and implement logic to securely read/write/delete values with unique keys.

Operations use default or overridden IaC (e.g Terraform modules) to provision the necessary resources for their target cloud.

Example AWS Provider
  • AWS DynamoDB serves as the key/value store backend.
  • AWS IAM provides roles and policies for secure access to DynamoDB tables.
Code
Terraform
Create DynamoDB
Store/Retrieve Data
Provide Access
Developer
Operations
nitric up
AWS DynamoDB
(Key/Value Store)
AWS Lambda Functions
AWS IAM
Example GCP Provider
  • Google Firestore serves as the key/value store backend.
  • Google IAM provides roles and policies for secure access to Firestore.
Code
Terraform
Create Firestore
Store/Retrieve Data
Provide Access
Developer
Operations
nitric up
Google Firestore
(Key/Value Store)
Google Cloud Functions
Google IAM

2. Sequence

Build Sequence

Below is a sequence diagram showing the sequence of events when a developer registers a Key/Value store with Nitric.

App Worker(s)Nitric SDKNitric CLINitric Provider (plugin)IaC (e.g. Terraform)Register Key/Value StoreRegister Access RequirementsRegister Key/Value StoreRegister Access RequirementsForward Nitric SpecProvision Key/Value StoreProvision IAMApp Worker(s)Nitric SDKNitric CLINitric Provider (plugin)IaC (e.g. Terraform)

Runtime Sequence

Below is a sequence diagram showing the runtime flow of a key/value store operation using Nitric. The example shows a Get operation, which reads a value by its key.

App CodeNitric SDKNitric Runtime (plugin)Document DB (e.g. AWS DynamoDB)Get(key)Forward RequestConvert RequestKey/Value API RequestApp CodeNitric SDKNitric Runtime (plugin)Document DB (e.g. AWS DynamoDB)

3. Component

Key/Value Store Module

  • Ensures unique identification of key-value stores by using a standardized naming convention or randomly generated identifiers.
  • Supports the definition of attributes, partition keys, and optional sort keys to optimize data organization and querying.
  • Provides scalable and cost-efficient storage configurations suitable for variable workloads.
  • Enables dynamic access control by assigning permissions to applications or services based on predefined roles and policies, ensuring least privilege access.
  • Offers support for event-driven workflows, allowing integration with notification systems or functions triggered by changes in the store.
  • Abstracts the underlying key-value storage implementation, enabling consistent developer and operations experience across different cloud providers.

4. Code

Developers write application code that uses the Key/Value resource from the SDK, configures the secret, and implements the application logic to access and manage secrets.

SDK Reference by language -

Operations will use or extend the Nitric infrastructure modules, including both Terraform and Pulumi:

Last updated on Feb 15, 2025