@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,92 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
5
|
+
import { DynamoDBDocumentClient, GetCommand } from '@aws-sdk/lib-dynamodb';
|
|
6
|
+
|
|
7
|
+
// Mock masking function for local development
|
|
8
|
+
// In production, this would come from a Lambda layer
|
|
9
|
+
const maskDocument = (document, config) => {
|
|
10
|
+
console.log('Applying masking with config:', config);
|
|
11
|
+
return document;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const ddbClient = new DynamoDBClient({});
|
|
15
|
+
const ddbDocClient = DynamoDBDocumentClient.from(ddbClient);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Lambda handler for retrieving documents with sensitive data masking
|
|
19
|
+
*/
|
|
20
|
+
export const handler = async (event) => {
|
|
21
|
+
try {
|
|
22
|
+
// Get document ID from path parameters
|
|
23
|
+
const documentId = event.pathParameters?.documentId;
|
|
24
|
+
|
|
25
|
+
if (!documentId) {
|
|
26
|
+
return {
|
|
27
|
+
statusCode: 400,
|
|
28
|
+
headers: {
|
|
29
|
+
'Content-Type': 'application/json'
|
|
30
|
+
},
|
|
31
|
+
body: JSON.stringify({
|
|
32
|
+
message: 'Missing document ID'
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Get document from DynamoDB
|
|
38
|
+
const result = await ddbDocClient.send(
|
|
39
|
+
new GetCommand({
|
|
40
|
+
TableName: process.env.METADATA_TABLE,
|
|
41
|
+
Key: { id: documentId }
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (!result.Item) {
|
|
46
|
+
return {
|
|
47
|
+
statusCode: 404,
|
|
48
|
+
headers: {
|
|
49
|
+
'Content-Type': 'application/json'
|
|
50
|
+
},
|
|
51
|
+
body: JSON.stringify({
|
|
52
|
+
message: 'Document not found'
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Get masking configuration from environment variable
|
|
58
|
+
let maskingConfig = {};
|
|
59
|
+
if (process.env.MASKING_CONFIG) {
|
|
60
|
+
try {
|
|
61
|
+
maskingConfig = JSON.parse(process.env.MASKING_CONFIG);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.warn('Invalid masking configuration:', error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Apply masking to the document
|
|
68
|
+
const maskedDocument = maskDocument(result.Item, maskingConfig);
|
|
69
|
+
|
|
70
|
+
// Return the masked document
|
|
71
|
+
return {
|
|
72
|
+
statusCode: 200,
|
|
73
|
+
headers: {
|
|
74
|
+
'Content-Type': 'application/json'
|
|
75
|
+
},
|
|
76
|
+
body: JSON.stringify(maskedDocument)
|
|
77
|
+
};
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error('Error retrieving document:', error);
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
statusCode: 500,
|
|
83
|
+
headers: {
|
|
84
|
+
'Content-Type': 'application/json'
|
|
85
|
+
},
|
|
86
|
+
body: JSON.stringify({
|
|
87
|
+
message: 'Error retrieving document',
|
|
88
|
+
error: error.message
|
|
89
|
+
})
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "default-doc-retrieval-lambda",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Lambda function for retrieving documents with sensitive data masking",
|
|
5
|
+
"main": "index.mjs",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"author": "Amazon Web Services",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"dependencies": {}
|
|
10
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
exports.handler = async (event) => {
|
|
2
|
+
console.log('Received error event:', JSON.stringify(event, null, 2));
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
// Extract error info from event
|
|
6
|
+
const { documentId, bucket, key, error, status } = event;
|
|
7
|
+
|
|
8
|
+
// Log the error details
|
|
9
|
+
console.error('Document processing failed:', {
|
|
10
|
+
documentId,
|
|
11
|
+
bucket,
|
|
12
|
+
key,
|
|
13
|
+
error,
|
|
14
|
+
status
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// In a real implementation, this would:
|
|
18
|
+
// 1. Move the failed document to error prefix in S3
|
|
19
|
+
// 2. Update metadata in DynamoDB
|
|
20
|
+
// 3. Trigger notifications if configured
|
|
21
|
+
// 4. Handle cleanup if needed
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
statusCode: 200,
|
|
25
|
+
documentId,
|
|
26
|
+
bucket,
|
|
27
|
+
key,
|
|
28
|
+
status: 'ERROR_HANDLED',
|
|
29
|
+
error: {
|
|
30
|
+
message: error,
|
|
31
|
+
handledAt: new Date().toISOString()
|
|
32
|
+
},
|
|
33
|
+
errorLocation: `failed/${documentId}`,
|
|
34
|
+
timestamp: new Date().toISOString()
|
|
35
|
+
};
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('Error handler failed:', error);
|
|
38
|
+
return {
|
|
39
|
+
statusCode: 500,
|
|
40
|
+
documentId: event.documentId,
|
|
41
|
+
error: error.message,
|
|
42
|
+
status: 'ERROR_HANDLER_FAILED',
|
|
43
|
+
timestamp: new Date().toISOString()
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|