AWS CDK constructs for ImmuKV - Immutable key-value store using S3 versioning
Project description
cdk-immukv
AWS CDK constructs for deploying ImmuKV infrastructure.
Installation
TypeScript/JavaScript
npm install cdk-immukv
Python
pip install cdk-immukv
Usage
Basic Setup
The ImmuKV construct uses a multi-prefix architecture. Each prefix defines an isolated ImmuKV namespace within a shared S3 bucket, with its own lifecycle rules, event notifications, IAM policies, and optional OIDC federation.
TypeScript
import * as cdk from "aws-cdk-lib";
import { ImmuKV } from "cdk-immukv";
const app = new cdk.App();
const stack = new cdk.Stack(app, "MyStack");
// Single prefix at bucket root
const store = new ImmuKV(stack, "ImmuKV", {
bucketName: "my-immukv-bucket",
prefixes: [{ s3Prefix: "" }],
});
// Access the prefix's IAM policies
store.prefix("").readWritePolicy;
store.prefix("").readOnlyPolicy;
Python
import aws_cdk as cdk
from cdk_immukv import ImmuKV
app = cdk.App()
stack = cdk.Stack(app, "MyStack")
store = ImmuKV(stack, "ImmuKV",
bucket_name="my-immukv-bucket",
prefixes=[{"s3_prefix": ""}],
)
Multi-Prefix Setup
Multiple prefixes share a single S3 bucket while remaining fully isolated at the IAM level.
import * as cdk from "aws-cdk-lib";
import * as s3n from "aws-cdk-lib/aws-s3-notifications";
import { ImmuKV } from "cdk-immukv";
const store = new ImmuKV(stack, "ImmuKV", {
prefixes: [
{
s3Prefix: "pipeline/",
logVersionRetention: cdk.Duration.days(2555),
onLogEntryCreated: new s3n.LambdaDestination(shadowUpdateFn),
},
{
s3Prefix: "config/",
logVersionRetention: cdk.Duration.days(90),
onLogEntryCreated: new s3n.LambdaDestination(configSyncFn),
},
],
});
// Access per-prefix resources
store.prefix("pipeline/").readWritePolicy;
store.prefix("config/").readOnlyPolicy;
S3 Event Notifications
Event notifications are configured per-prefix. Each prefix can have its own notification destination triggered when log entries are created. Supports Lambda functions, SNS topics, and SQS queues.
TypeScript - Lambda Trigger
import * as cdk from "aws-cdk-lib";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as s3n from "aws-cdk-lib/aws-s3-notifications";
import { ImmuKV } from "cdk-immukv";
const processorFn = new lambda.Function(stack, "LogProcessor", {
runtime: lambda.Runtime.PYTHON_3_11,
handler: "index.handler",
code: lambda.Code.fromAsset("lambda"),
});
new ImmuKV(stack, "ImmuKV", {
bucketName: "my-immukv-bucket",
prefixes: [
{
s3Prefix: "",
onLogEntryCreated: new s3n.LambdaDestination(processorFn),
},
],
});
TypeScript - SNS Topic
import * as sns from "aws-cdk-lib/aws-sns";
import * as s3n from "aws-cdk-lib/aws-s3-notifications";
import { ImmuKV } from "cdk-immukv";
const topic = new sns.Topic(stack, "LogEntryTopic");
new ImmuKV(stack, "ImmuKV", {
bucketName: "my-immukv-bucket",
prefixes: [
{
s3Prefix: "",
onLogEntryCreated: new s3n.SnsDestination(topic),
},
],
});
TypeScript - SQS Queue
import * as sqs from "aws-cdk-lib/aws-sqs";
import * as s3n from "aws-cdk-lib/aws-s3-notifications";
import { ImmuKV } from "cdk-immukv";
const queue = new sqs.Queue(stack, "LogEntryQueue");
new ImmuKV(stack, "ImmuKV", {
bucketName: "my-immukv-bucket",
prefixes: [
{
s3Prefix: "",
onLogEntryCreated: new s3n.SqsDestination(queue),
},
],
});
Python - Lambda Trigger
import aws_cdk as cdk
from aws_cdk import aws_lambda as lambda_
from aws_cdk.aws_s3_notifications import LambdaDestination
from cdk_immukv import ImmuKV
processor_fn = lambda_.Function(stack, "LogProcessor",
runtime=lambda_.Runtime.PYTHON_3_11,
handler="index.handler",
code=lambda_.Code.from_asset("lambda"),
)
ImmuKV(stack, "ImmuKV",
bucket_name="my-immukv-bucket",
prefixes=[{
"s3_prefix": "",
"on_log_entry_created": LambdaDestination(processor_fn),
}],
)
OIDC Federation
OIDC identity providers are configured per-prefix. Each prefix can have its own federated IAM role scoped to that prefix's resources.
import { ImmuKV } from "cdk-immukv";
const store = new ImmuKV(stack, "ImmuKV", {
prefixes: [
{
s3Prefix: "app/",
oidcProviders: [
{
issuerUrl: "https://accounts.google.com",
clientIds: ["your-client-id.apps.googleusercontent.com"],
},
],
// oidcReadOnly: true, // Set to true for read-only federated access
},
],
});
// The federated role is available on the prefix resources
store.prefix("app/").federatedRole; // IAM role for OIDC users
API
ImmuKVProps
Top-level properties for the ImmuKV construct:
bucketName(optional): Name for the S3 bucket. If not specified, an auto-generated bucket name will be used.useKmsEncryption(optional): Enable KMS encryption instead of S3-managed encryption (default: false).prefixes(required): Array ofImmuKVPrefixConfigentries. At least one entry is required.
ImmuKVPrefixConfig
Configuration for a single ImmuKV prefix within the bucket:
s3Prefix(required): S3 key prefix for this namespace. Use""for bucket root, or directory-style like"myapp/"for namespacing.logVersionRetention(optional): Duration to retain old log versions. Must be expressible in whole days.logVersionsToRetain(optional): Number of old log versions to retain.keyVersionRetention(optional): Duration to retain old key object versions. Must be expressible in whole days.keyVersionsToRetain(optional): Number of old key versions to retain per key.onLogEntryCreated(optional): S3 notification destination triggered when log entries are created under this prefix. Supports Lambda, SNS, and SQS.oidcProviders(optional): Array of OIDC identity providers for web identity federation scoped to this prefix. Each provider has anissuerUrl(must start with"https://") andclientIds(audiences to trust).oidcReadOnly(optional): Whether the federated role gets read-only access instead of read-write (default: false).
Prefix Validation Rules
- Prefixes must not start with
/or contain.. - Duplicate prefixes are not allowed
- Overlapping prefixes are not allowed (one being a prefix of the other)
- Empty string prefix
""cannot coexist with other prefixes (it matches all objects)
ImmuKV Class
The ImmuKV construct exposes:
bucket: The S3 bucket shared by all prefixes.prefixes: Object mapping prefix strings toImmuKVPrefixResources.prefix(s3Prefix): Method to get resources for a specific prefix (throws if not found).
ImmuKVPrefixResources
Resources created for each prefix:
s3Prefix: The S3 prefix string (as provided in the config).readWritePolicy: IAM managed policy granting read-write access scoped to this prefix.readOnlyPolicy: IAM managed policy granting read-only access scoped to this prefix.federatedRole(optional): Federated IAM role for OIDC users scoped to this prefix. Only present whenoidcProviderswas specified.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cdk_immukv-0.1.25.tar.gz.
File metadata
- Download URL: cdk_immukv-0.1.25.tar.gz
- Upload date:
- Size: 50.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d500b406ddcc59fc1b8da94aa624273f4d4a78fd8d793e2973d8ef1fbdf2334f
|
|
| MD5 |
e5f26a465303e716e23f3a21881dfb90
|
|
| BLAKE2b-256 |
7f4e3cebcfc9463c842dd8cf9dc1ac69e67f14867a3eaf061c8ddfc7ee8ac87b
|
Provenance
The following attestation bundles were made for cdk_immukv-0.1.25.tar.gz:
Publisher:
build.yml on Portfoligno/immukv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cdk_immukv-0.1.25.tar.gz -
Subject digest:
d500b406ddcc59fc1b8da94aa624273f4d4a78fd8d793e2973d8ef1fbdf2334f - Sigstore transparency entry: 976482798
- Sigstore integration time:
-
Permalink:
Portfoligno/immukv@a66ef3d224131131e6e142a4286b0e4b78772f21 -
Branch / Tag:
refs/tags/0.1.25 - Owner: https://github.com/Portfoligno
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@a66ef3d224131131e6e142a4286b0e4b78772f21 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cdk_immukv-0.1.25-py3-none-any.whl.
File metadata
- Download URL: cdk_immukv-0.1.25-py3-none-any.whl
- Upload date:
- Size: 47.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21ba7a79475111b2ca3e3681ae459afa5cb0c257008de834111f02dbb61a3fe8
|
|
| MD5 |
65062d83de4292dabeb2cbd3a2873bf7
|
|
| BLAKE2b-256 |
22193b6486cea6a23afb68587caf54f78a7ebee1c940cbfbd9f354d6336baadd
|
Provenance
The following attestation bundles were made for cdk_immukv-0.1.25-py3-none-any.whl:
Publisher:
build.yml on Portfoligno/immukv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cdk_immukv-0.1.25-py3-none-any.whl -
Subject digest:
21ba7a79475111b2ca3e3681ae459afa5cb0c257008de834111f02dbb61a3fe8 - Sigstore transparency entry: 976482800
- Sigstore integration time:
-
Permalink:
Portfoligno/immukv@a66ef3d224131131e6e142a4286b0e4b78772f21 -
Branch / Tag:
refs/tags/0.1.25 - Owner: https://github.com/Portfoligno
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@a66ef3d224131131e6e142a4286b0e4b78772f21 -
Trigger Event:
push
-
Statement type: