@mettlecast/domain-cdk-packer
v0.2.55
Published
AWS CDK L3 constructs that compile a `DomainRegistry` snapshot into CloudFormation. Takes the output of `mc-domain-module build` and generates type-safe infrastructure.
Readme
@mettlecast/domain-cdk-packer
AWS CDK L3 constructs that compile a DomainRegistry snapshot into CloudFormation. Takes the output of mc-domain-module build and generates type-safe infrastructure.
Install
npm install @mettlecast/domain-cdk-packer --save-devQuick Start
Pack a domain registry into a CDK stack:
import { packDomain } from '@mettlecast/domain-cdk-packer';
import * as cdk from 'aws-cdk-lib';
import * as fs from 'fs';
const app = new cdk.App();
const registry = JSON.parse(
fs.readFileSync('.mc/domain-registry.json', 'utf-8')
);
packDomain(registry, app, {
env: { region: 'eu-north-1', account: '123456789' },
});
app.synth();Or use DomainStack directly:
import { DomainStack } from '@mettlecast/domain-cdk-packer';
new DomainStack(app, 'PaymentsStack', {
registry,
env: { region: 'eu-north-1', account: '123456789' },
});Constructs Generated
For each handler in the registry, the packer provisions:
| Handler Type | Generated Constructs |
|---|---|
| defineApi() | Lambda function, API Gateway route (method + path), EventBridge integration |
| defineWebhook() | Lambda function, API Gateway webhook route, GitHub webhook validation |
| defineSubscriber() | Lambda function, EventBridge rule (event filter), Lambda target |
| defineSchedule() | Lambda function, EventBridge Scheduler rule (cron expression) |
| defineJob() | Lambda function, SQS queue, Lambda event source mapping |
| defineAction() | Lambda function, Function URL (for workspace invocation) |
| defineIntegration() | Lambda function, SQS DLQ, error retry logic |
All handlers use esbuild for bundling and Drizzle ORM for database access.
Advanced Features
StepFunctionsCodegen — Convert domain actions into AWS Step Functions task states for TIB Flow Designer integration:
import { StepFunctionsCodegen } from '@mettlecast/domain-cdk-packer';
const sfnCodegen = new StepFunctionsCodegen(registry);
const taskStates = sfnCodegen.generate();
// taskStates: StepFunctionsTaskState[] — ready to be serialized to Flow DesignerPeer Dependencies
@mettlecast/domain-cdk-packer requires:
aws-cdk-lib(^2.0)constructs(^10.0)
And expects @mettlecast/domain-runtime to be installed in the same project (used for type reflection).
See Also
@mettlecast/domain-runtime— handler definitions@mettlecast/domain-cli— local build and validation
