@cdklabs/cdk-appmod-catalog-blueprints 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +8644 -0
- package/LICENSE +202 -0
- package/README.md +212 -0
- package/lib/document-processing/agentic-document-processing.d.ts +16 -0
- package/lib/document-processing/agentic-document-processing.js +90 -0
- package/lib/document-processing/base-document-processing.d.ts +189 -0
- package/lib/document-processing/base-document-processing.js +509 -0
- package/lib/document-processing/bedrock-document-processing.d.ts +167 -0
- package/lib/document-processing/bedrock-document-processing.js +297 -0
- package/lib/document-processing/index.d.ts +3 -0
- package/lib/document-processing/index.js +20 -0
- package/lib/document-processing/resources/default-bedrock-invoke/index.py +63 -0
- package/lib/document-processing/resources/default-bedrock-invoke/requirements.txt +4 -0
- package/lib/document-processing/resources/default-doc-retrieval-lambda/index.mjs +92 -0
- package/lib/document-processing/resources/default-doc-retrieval-lambda/package.json +10 -0
- package/lib/document-processing/resources/default-error-handler/index.js +46 -0
- package/lib/document-processing/resources/default-error-handler/package.json +4 -0
- package/lib/document-processing/resources/default-image-processor/classifier.mjs +665 -0
- package/lib/document-processing/resources/default-image-processor/extractors.mjs +465 -0
- package/lib/document-processing/resources/default-image-processor/index.mjs +143 -0
- package/lib/document-processing/resources/default-image-processor/package-lock.json +12 -0
- package/lib/document-processing/resources/default-image-processor/package.json +4 -0
- package/lib/document-processing/resources/default-image-validator/index.mjs +76 -0
- package/lib/document-processing/resources/default-image-validator/package-lock.json +154 -0
- package/lib/document-processing/resources/default-image-validator/package.json +7 -0
- package/lib/document-processing/resources/default-pdf-processor/index.js +46 -0
- package/lib/document-processing/resources/default-pdf-validator/index.js +36 -0
- package/lib/document-processing/resources/default-sqs-consumer/index.py +111 -0
- package/lib/document-processing/resources/default-sqs-consumer/requirements.txt +4 -0
- package/lib/document-processing/resources/default-sqs-consumer/sample_payload.json +20 -0
- package/lib/document-processing/resources/default-sqs-consumer/sample_payload_multi.json +24 -0
- package/lib/document-processing/resources/default-strands-agent/index.py +111 -0
- package/lib/document-processing/resources/default-strands-agent/requirements.txt +6 -0
- package/lib/document-processing/tests/agentic-document-processing-nag.test.d.ts +1 -0
- package/lib/document-processing/tests/agentic-document-processing-nag.test.js +107 -0
- package/lib/document-processing/tests/agentic-document-processing.test.d.ts +1 -0
- package/lib/document-processing/tests/agentic-document-processing.test.js +125 -0
- package/lib/document-processing/tests/bedrock-document-processing-nag.test.d.ts +1 -0
- package/lib/document-processing/tests/bedrock-document-processing-nag.test.js +101 -0
- package/lib/document-processing/tests/bedrock-document-processing.test.d.ts +1 -0
- package/lib/document-processing/tests/bedrock-document-processing.test.js +79 -0
- package/lib/framework/custom-resource/default-runtimes.d.ts +21 -0
- package/lib/framework/custom-resource/default-runtimes.js +34 -0
- package/lib/framework/custom-resource/index.d.ts +1 -0
- package/lib/framework/custom-resource/index.js +18 -0
- package/lib/framework/foundation/access-log.d.ts +69 -0
- package/lib/framework/foundation/access-log.js +121 -0
- package/lib/framework/foundation/eventbridge-broker.d.ts +18 -0
- package/lib/framework/foundation/eventbridge-broker.js +42 -0
- package/lib/framework/foundation/index.d.ts +3 -0
- package/lib/framework/foundation/index.js +20 -0
- package/lib/framework/foundation/network.d.ts +19 -0
- package/lib/framework/foundation/network.js +83 -0
- package/lib/framework/index.d.ts +2 -0
- package/lib/framework/index.js +19 -0
- package/lib/framework/quickstart/base-quickstart.d.ts +30 -0
- package/lib/framework/quickstart/base-quickstart.js +30 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +21 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/utilities/cdk-nag-config.d.ts +42 -0
- package/lib/utilities/cdk-nag-config.js +194 -0
- package/lib/utilities/data-loader-lambda/index.py +282 -0
- package/lib/utilities/data-loader-lambda/requirements.txt +3 -0
- package/lib/utilities/data-loader.d.ts +173 -0
- package/lib/utilities/data-loader.js +447 -0
- package/lib/utilities/index.d.ts +3 -0
- package/lib/utilities/index.js +20 -0
- package/lib/utilities/lambda-iam-utils.d.ts +145 -0
- package/lib/utilities/lambda-iam-utils.js +235 -0
- package/lib/utilities/lambda_layers/data-masking/layer-construct.d.ts +42 -0
- package/lib/utilities/lambda_layers/data-masking/layer-construct.js +53 -0
- package/lib/utilities/lambda_layers/data-masking/layer-construct.ts +88 -0
- package/lib/utilities/observability/bedrock-observability.d.ts +18 -0
- package/lib/utilities/observability/bedrock-observability.js +131 -0
- package/lib/utilities/observability/cloudfront-distribution-observability-property-injector.d.ts +6 -0
- package/lib/utilities/observability/cloudfront-distribution-observability-property-injector.js +22 -0
- package/lib/utilities/observability/index.d.ts +6 -0
- package/lib/utilities/observability/index.js +25 -0
- package/lib/utilities/observability/lambda-observability-property-injector.d.ts +8 -0
- package/lib/utilities/observability/lambda-observability-property-injector.js +43 -0
- package/lib/utilities/observability/log-group-data-protection-props.d.ts +19 -0
- package/lib/utilities/observability/log-group-data-protection-props.js +5 -0
- package/lib/utilities/observability/observability.d.ts +83 -0
- package/lib/utilities/observability/observability.js +278 -0
- package/lib/utilities/observability/observable.d.ts +32 -0
- package/lib/utilities/observability/observable.js +3 -0
- package/lib/utilities/observability/powertools-config.d.ts +3 -0
- package/lib/utilities/observability/powertools-config.js +25 -0
- package/lib/utilities/observability/resources/bedrock-manage-logging-configuration/index.py +27 -0
- package/lib/utilities/observability/state-machine-observability-property-injector.d.ts +8 -0
- package/lib/utilities/observability/state-machine-observability-property-injector.js +49 -0
- package/lib/utilities/tests/data-loader-nag.test.d.ts +1 -0
- package/lib/utilities/tests/data-loader-nag.test.js +432 -0
- package/lib/utilities/tests/data-loader.test.d.ts +1 -0
- package/lib/utilities/tests/data-loader.test.js +284 -0
- package/lib/webapp/frontend-construct.d.ts +136 -0
- package/lib/webapp/frontend-construct.js +253 -0
- package/lib/webapp/index.d.ts +1 -0
- package/lib/webapp/index.js +18 -0
- package/lib/webapp/tests/frontend-construct-nag.test.d.ts +1 -0
- package/lib/webapp/tests/frontend-construct-nag.test.js +266 -0
- package/lib/webapp/tests/frontend-construct.test.d.ts +1 -0
- package/lib/webapp/tests/frontend-construct.test.js +385 -0
- package/package.json +183 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { Duration, RemovalPolicy } from 'aws-cdk-lib';
|
|
2
|
+
import { IMetric } from 'aws-cdk-lib/aws-cloudwatch';
|
|
3
|
+
import { Table } from 'aws-cdk-lib/aws-dynamodb';
|
|
4
|
+
import { IKey, Key } from 'aws-cdk-lib/aws-kms';
|
|
5
|
+
import { Bucket } from 'aws-cdk-lib/aws-s3';
|
|
6
|
+
import { Queue } from 'aws-cdk-lib/aws-sqs';
|
|
7
|
+
import { StateMachine } from 'aws-cdk-lib/aws-stepfunctions';
|
|
8
|
+
import { BedrockInvokeModel, LambdaInvoke, StepFunctionsStartExecution } from 'aws-cdk-lib/aws-stepfunctions-tasks';
|
|
9
|
+
import { Construct } from 'constructs';
|
|
10
|
+
import { Network } from '../framework';
|
|
11
|
+
import { EventbridgeBroker } from '../framework/foundation/eventbridge-broker';
|
|
12
|
+
import { LogGroupDataProtectionProps } from '../utilities';
|
|
13
|
+
import { IObservable, ObservableProps } from '../utilities/observability/observable';
|
|
14
|
+
/**
|
|
15
|
+
* Configuration properties for BaseDocumentProcessing construct.
|
|
16
|
+
*/
|
|
17
|
+
export interface BaseDocumentProcessingProps extends ObservableProps {
|
|
18
|
+
/**
|
|
19
|
+
* S3 bucket for document storage with organized prefixes (raw/, processed/, failed/).
|
|
20
|
+
* If not provided, a new bucket will be created with auto-delete enabled based on removalPolicy.
|
|
21
|
+
*/
|
|
22
|
+
readonly bucket?: Bucket;
|
|
23
|
+
/**
|
|
24
|
+
* DynamoDB table for storing document processing metadata and workflow state.
|
|
25
|
+
* If not provided, a new table will be created with DocumentId as partition key.
|
|
26
|
+
*/
|
|
27
|
+
readonly documentProcessingTable?: Table;
|
|
28
|
+
/**
|
|
29
|
+
* SQS queue visibility timeout for processing messages.
|
|
30
|
+
* Should be longer than expected processing time to prevent duplicate processing.
|
|
31
|
+
* @default Duration.seconds(300)
|
|
32
|
+
*/
|
|
33
|
+
readonly queueVisibilityTimeout?: Duration;
|
|
34
|
+
/**
|
|
35
|
+
* The number of times a message can be unsuccessfully dequeued before being moved to the dead-letter queue.
|
|
36
|
+
*
|
|
37
|
+
* @default 5
|
|
38
|
+
*/
|
|
39
|
+
readonly dlqMaxReceiveCount?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum execution time for the Step Functions workflow.
|
|
42
|
+
* @default Duration.minutes(30)
|
|
43
|
+
*/
|
|
44
|
+
readonly workflowTimeout?: Duration;
|
|
45
|
+
/**
|
|
46
|
+
* Removal policy for created resources (bucket, table, queue).
|
|
47
|
+
* @default RemovalPolicy.DESTROY
|
|
48
|
+
*/
|
|
49
|
+
readonly removalPolicy?: RemovalPolicy;
|
|
50
|
+
/**
|
|
51
|
+
* Optional EventBridge broker for publishing custom events during processing.
|
|
52
|
+
* If not provided, no custom events will be sent out.
|
|
53
|
+
*/
|
|
54
|
+
readonly eventbridgeBroker?: EventbridgeBroker;
|
|
55
|
+
/**
|
|
56
|
+
* Enable logging and tracing for all supporting resource
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
readonly enableObservability?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Resources that can run inside a VPC will follow the provided network configuration
|
|
62
|
+
* @default resources will run outside of a VPC
|
|
63
|
+
*/
|
|
64
|
+
readonly network?: Network;
|
|
65
|
+
/**
|
|
66
|
+
* KMS key to be used.
|
|
67
|
+
* @default A new key would be created
|
|
68
|
+
*/
|
|
69
|
+
readonly encryptionKey?: Key;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* S3 prefix constants for organizing documents throughout the processing lifecycle.
|
|
73
|
+
*
|
|
74
|
+
* Documents flow through these prefixes based on processing outcomes:
|
|
75
|
+
* - Upload → raw/ (triggers processing)
|
|
76
|
+
* - Success → processed/ (workflow completed successfully)
|
|
77
|
+
* - Failure → failed/ (workflow encountered errors)
|
|
78
|
+
*/
|
|
79
|
+
export declare enum DocumentProcessingPrefix {
|
|
80
|
+
/** Prefix for newly uploaded documents awaiting processing */
|
|
81
|
+
RAW = "raw/",
|
|
82
|
+
/** Prefix for documents that failed processing */
|
|
83
|
+
FAILED = "failed/",
|
|
84
|
+
/** Prefix for successfully processed documents */
|
|
85
|
+
PROCESSED = "processed/"
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Union type for Step Functions tasks that can be used in document processing workflows.
|
|
89
|
+
* Supports Bedrock model invocation, Lambda function invocation, and nested Step Functions execution.
|
|
90
|
+
*/
|
|
91
|
+
export type DocumentProcessingStepType = BedrockInvokeModel | LambdaInvoke | StepFunctionsStartExecution;
|
|
92
|
+
/**
|
|
93
|
+
* Abstract base class for serverless document processing workflows.
|
|
94
|
+
*
|
|
95
|
+
* Provides a complete document processing pipeline with:
|
|
96
|
+
* - **S3 Storage**: Organized with prefixes (raw/, processed/, failed/) for document lifecycle management
|
|
97
|
+
* - **SQS Queue**: Reliable message processing with configurable visibility timeout and dead letter queue
|
|
98
|
+
* - **DynamoDB Table**: Workflow metadata tracking with DocumentId as partition key
|
|
99
|
+
* - **Step Functions**: Orchestrated workflow with automatic file movement based on processing outcome
|
|
100
|
+
* - **Auto-triggering**: S3 event notifications automatically start processing when files are uploaded to raw/ prefix
|
|
101
|
+
* - **Error Handling**: Failed documents are moved to failed/ prefix with error details stored in DynamoDB
|
|
102
|
+
* - **EventBridge Integration**: Optional custom event publishing for workflow state changes
|
|
103
|
+
*
|
|
104
|
+
* ## Architecture Flow
|
|
105
|
+
* S3 Upload (raw/) → SQS → Lambda Consumer → Step Functions → Processing Steps → S3 (processed/failed/)
|
|
106
|
+
*
|
|
107
|
+
* ## Implementation Requirements
|
|
108
|
+
* Subclasses must implement four abstract methods to define the processing workflow:
|
|
109
|
+
* - `classificationStep()`: Document type classification
|
|
110
|
+
* - `extractionStep()`: Data extraction from documents
|
|
111
|
+
* - `enrichmentStep()`: Optional data enrichment (return undefined to skip)
|
|
112
|
+
* - `postProcessingStep()`: Optional post-processing (return undefined to skip)
|
|
113
|
+
*/
|
|
114
|
+
export declare abstract class BaseDocumentProcessing extends Construct implements IObservable {
|
|
115
|
+
/** Business metric service name. This is part of the initial service dimension */
|
|
116
|
+
readonly metricServiceName: string;
|
|
117
|
+
/** Business metric namespace. */
|
|
118
|
+
readonly metricNamespace: string;
|
|
119
|
+
/** log group data protection configuration */
|
|
120
|
+
readonly logGroupDataProtection: LogGroupDataProtectionProps;
|
|
121
|
+
/** S3 bucket for document storage with organized prefixes (raw/, processed/, failed/) */
|
|
122
|
+
readonly bucket: Bucket;
|
|
123
|
+
/** SQS queue for reliable message processing with dead letter queue support */
|
|
124
|
+
readonly queue: Queue;
|
|
125
|
+
/** DynamoDB table for storing document processing metadata and workflow state */
|
|
126
|
+
readonly documentProcessingTable: Table;
|
|
127
|
+
/** Configuration properties for the document processing pipeline */
|
|
128
|
+
private readonly props;
|
|
129
|
+
/** Dead letter queue */
|
|
130
|
+
readonly deadLetterQueue: Queue;
|
|
131
|
+
/** KMS key */
|
|
132
|
+
readonly encryptionKey: Key;
|
|
133
|
+
/** Encryption key used by the DocumentProcessingBucket */
|
|
134
|
+
readonly bucketEncryptionKey?: IKey;
|
|
135
|
+
/**
|
|
136
|
+
* Creates a new BaseDocumentProcessing construct.
|
|
137
|
+
*
|
|
138
|
+
* Initializes the complete document processing infrastructure including S3 bucket,
|
|
139
|
+
* SQS queue, DynamoDB table, and sets up S3 event notifications to trigger processing.
|
|
140
|
+
*
|
|
141
|
+
* @param scope - The scope in which to define this construct
|
|
142
|
+
* @param id - The scoped construct ID. Must be unique within the scope.
|
|
143
|
+
* @param props - Configuration properties for the document processing pipeline
|
|
144
|
+
*/
|
|
145
|
+
constructor(scope: Construct, id: string, props: BaseDocumentProcessingProps);
|
|
146
|
+
protected handleStateMachineCreation(stateMachineId: string): StateMachine;
|
|
147
|
+
protected handleWorkflowTrigger(stateMachine: StateMachine): void;
|
|
148
|
+
private createSQSConsumerLambda;
|
|
149
|
+
private createStateMachineRole;
|
|
150
|
+
private createMoveToFailedChain;
|
|
151
|
+
private createMoveToProcessedChain;
|
|
152
|
+
metrics(): IMetric[];
|
|
153
|
+
/**
|
|
154
|
+
* Defines the document classification step of the workflow.
|
|
155
|
+
*
|
|
156
|
+
* **CRITICAL**: Must set `outputPath` to preserve workflow state for subsequent steps.
|
|
157
|
+
* The classification result should be available at `$.classificationResult` for DynamoDB storage.
|
|
158
|
+
*
|
|
159
|
+
* @returns Step Functions task for document classification
|
|
160
|
+
*/
|
|
161
|
+
protected abstract classificationStep(): DocumentProcessingStepType;
|
|
162
|
+
/**
|
|
163
|
+
* Defines the document processing step of the workflow.
|
|
164
|
+
*
|
|
165
|
+
* **CRITICAL**: Must set `outputPath` to preserve workflow state for subsequent steps.
|
|
166
|
+
* The extraction result should be available at `$.processingResult` for DynamoDB storage.
|
|
167
|
+
*
|
|
168
|
+
* @returns Step Functions task for document extraction
|
|
169
|
+
*/
|
|
170
|
+
protected abstract processingStep(): DocumentProcessingStepType;
|
|
171
|
+
/**
|
|
172
|
+
* Defines the optional document enrichment step of the workflow.
|
|
173
|
+
*
|
|
174
|
+
* **CRITICAL**: If implemented, must set `outputPath` to preserve workflow state.
|
|
175
|
+
* The enrichment result should be available at `$.enrichedResult` for DynamoDB storage.
|
|
176
|
+
*
|
|
177
|
+
* @returns Step Functions task for document enrichment, or undefined to skip this step
|
|
178
|
+
*/
|
|
179
|
+
protected abstract enrichmentStep(): DocumentProcessingStepType | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* Defines the optional post-processing step of the workflow.
|
|
182
|
+
*
|
|
183
|
+
* **CRITICAL**: If implemented, must set `outputPath` to preserve workflow state.
|
|
184
|
+
* The post-processing result should be available at `$.postProcessedResult` for DynamoDB storage.
|
|
185
|
+
*
|
|
186
|
+
* @returns Step Functions task for post-processing, or undefined to skip this step
|
|
187
|
+
*/
|
|
188
|
+
protected abstract postProcessingStep(): DocumentProcessingStepType | undefined;
|
|
189
|
+
}
|