@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.
Files changed (105) hide show
  1. package/.jsii +8644 -0
  2. package/LICENSE +202 -0
  3. package/README.md +212 -0
  4. package/lib/document-processing/agentic-document-processing.d.ts +16 -0
  5. package/lib/document-processing/agentic-document-processing.js +90 -0
  6. package/lib/document-processing/base-document-processing.d.ts +189 -0
  7. package/lib/document-processing/base-document-processing.js +509 -0
  8. package/lib/document-processing/bedrock-document-processing.d.ts +167 -0
  9. package/lib/document-processing/bedrock-document-processing.js +297 -0
  10. package/lib/document-processing/index.d.ts +3 -0
  11. package/lib/document-processing/index.js +20 -0
  12. package/lib/document-processing/resources/default-bedrock-invoke/index.py +63 -0
  13. package/lib/document-processing/resources/default-bedrock-invoke/requirements.txt +4 -0
  14. package/lib/document-processing/resources/default-doc-retrieval-lambda/index.mjs +92 -0
  15. package/lib/document-processing/resources/default-doc-retrieval-lambda/package.json +10 -0
  16. package/lib/document-processing/resources/default-error-handler/index.js +46 -0
  17. package/lib/document-processing/resources/default-error-handler/package.json +4 -0
  18. package/lib/document-processing/resources/default-image-processor/classifier.mjs +665 -0
  19. package/lib/document-processing/resources/default-image-processor/extractors.mjs +465 -0
  20. package/lib/document-processing/resources/default-image-processor/index.mjs +143 -0
  21. package/lib/document-processing/resources/default-image-processor/package-lock.json +12 -0
  22. package/lib/document-processing/resources/default-image-processor/package.json +4 -0
  23. package/lib/document-processing/resources/default-image-validator/index.mjs +76 -0
  24. package/lib/document-processing/resources/default-image-validator/package-lock.json +154 -0
  25. package/lib/document-processing/resources/default-image-validator/package.json +7 -0
  26. package/lib/document-processing/resources/default-pdf-processor/index.js +46 -0
  27. package/lib/document-processing/resources/default-pdf-validator/index.js +36 -0
  28. package/lib/document-processing/resources/default-sqs-consumer/index.py +111 -0
  29. package/lib/document-processing/resources/default-sqs-consumer/requirements.txt +4 -0
  30. package/lib/document-processing/resources/default-sqs-consumer/sample_payload.json +20 -0
  31. package/lib/document-processing/resources/default-sqs-consumer/sample_payload_multi.json +24 -0
  32. package/lib/document-processing/resources/default-strands-agent/index.py +111 -0
  33. package/lib/document-processing/resources/default-strands-agent/requirements.txt +6 -0
  34. package/lib/document-processing/tests/agentic-document-processing-nag.test.d.ts +1 -0
  35. package/lib/document-processing/tests/agentic-document-processing-nag.test.js +107 -0
  36. package/lib/document-processing/tests/agentic-document-processing.test.d.ts +1 -0
  37. package/lib/document-processing/tests/agentic-document-processing.test.js +125 -0
  38. package/lib/document-processing/tests/bedrock-document-processing-nag.test.d.ts +1 -0
  39. package/lib/document-processing/tests/bedrock-document-processing-nag.test.js +101 -0
  40. package/lib/document-processing/tests/bedrock-document-processing.test.d.ts +1 -0
  41. package/lib/document-processing/tests/bedrock-document-processing.test.js +79 -0
  42. package/lib/framework/custom-resource/default-runtimes.d.ts +21 -0
  43. package/lib/framework/custom-resource/default-runtimes.js +34 -0
  44. package/lib/framework/custom-resource/index.d.ts +1 -0
  45. package/lib/framework/custom-resource/index.js +18 -0
  46. package/lib/framework/foundation/access-log.d.ts +69 -0
  47. package/lib/framework/foundation/access-log.js +121 -0
  48. package/lib/framework/foundation/eventbridge-broker.d.ts +18 -0
  49. package/lib/framework/foundation/eventbridge-broker.js +42 -0
  50. package/lib/framework/foundation/index.d.ts +3 -0
  51. package/lib/framework/foundation/index.js +20 -0
  52. package/lib/framework/foundation/network.d.ts +19 -0
  53. package/lib/framework/foundation/network.js +83 -0
  54. package/lib/framework/index.d.ts +2 -0
  55. package/lib/framework/index.js +19 -0
  56. package/lib/framework/quickstart/base-quickstart.d.ts +30 -0
  57. package/lib/framework/quickstart/base-quickstart.js +30 -0
  58. package/lib/index.d.ts +4 -0
  59. package/lib/index.js +21 -0
  60. package/lib/tsconfig.tsbuildinfo +1 -0
  61. package/lib/utilities/cdk-nag-config.d.ts +42 -0
  62. package/lib/utilities/cdk-nag-config.js +194 -0
  63. package/lib/utilities/data-loader-lambda/index.py +282 -0
  64. package/lib/utilities/data-loader-lambda/requirements.txt +3 -0
  65. package/lib/utilities/data-loader.d.ts +173 -0
  66. package/lib/utilities/data-loader.js +447 -0
  67. package/lib/utilities/index.d.ts +3 -0
  68. package/lib/utilities/index.js +20 -0
  69. package/lib/utilities/lambda-iam-utils.d.ts +145 -0
  70. package/lib/utilities/lambda-iam-utils.js +235 -0
  71. package/lib/utilities/lambda_layers/data-masking/layer-construct.d.ts +42 -0
  72. package/lib/utilities/lambda_layers/data-masking/layer-construct.js +53 -0
  73. package/lib/utilities/lambda_layers/data-masking/layer-construct.ts +88 -0
  74. package/lib/utilities/observability/bedrock-observability.d.ts +18 -0
  75. package/lib/utilities/observability/bedrock-observability.js +131 -0
  76. package/lib/utilities/observability/cloudfront-distribution-observability-property-injector.d.ts +6 -0
  77. package/lib/utilities/observability/cloudfront-distribution-observability-property-injector.js +22 -0
  78. package/lib/utilities/observability/index.d.ts +6 -0
  79. package/lib/utilities/observability/index.js +25 -0
  80. package/lib/utilities/observability/lambda-observability-property-injector.d.ts +8 -0
  81. package/lib/utilities/observability/lambda-observability-property-injector.js +43 -0
  82. package/lib/utilities/observability/log-group-data-protection-props.d.ts +19 -0
  83. package/lib/utilities/observability/log-group-data-protection-props.js +5 -0
  84. package/lib/utilities/observability/observability.d.ts +83 -0
  85. package/lib/utilities/observability/observability.js +278 -0
  86. package/lib/utilities/observability/observable.d.ts +32 -0
  87. package/lib/utilities/observability/observable.js +3 -0
  88. package/lib/utilities/observability/powertools-config.d.ts +3 -0
  89. package/lib/utilities/observability/powertools-config.js +25 -0
  90. package/lib/utilities/observability/resources/bedrock-manage-logging-configuration/index.py +27 -0
  91. package/lib/utilities/observability/state-machine-observability-property-injector.d.ts +8 -0
  92. package/lib/utilities/observability/state-machine-observability-property-injector.js +49 -0
  93. package/lib/utilities/tests/data-loader-nag.test.d.ts +1 -0
  94. package/lib/utilities/tests/data-loader-nag.test.js +432 -0
  95. package/lib/utilities/tests/data-loader.test.d.ts +1 -0
  96. package/lib/utilities/tests/data-loader.test.js +284 -0
  97. package/lib/webapp/frontend-construct.d.ts +136 -0
  98. package/lib/webapp/frontend-construct.js +253 -0
  99. package/lib/webapp/index.d.ts +1 -0
  100. package/lib/webapp/index.js +18 -0
  101. package/lib/webapp/tests/frontend-construct-nag.test.d.ts +1 -0
  102. package/lib/webapp/tests/frontend-construct-nag.test.js +266 -0
  103. package/lib/webapp/tests/frontend-construct.test.d.ts +1 -0
  104. package/lib/webapp/tests/frontend-construct.test.js +385 -0
  105. package/package.json +183 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # AppMod Use Case Blueprints
2
+
3
+ Serverless infrastructure components for modern application development. This catalog provides composable building blocks organized by business use cases, enabling rapid deployment of secure, scalable solutions.
4
+
5
+ ## Quick Start
6
+
7
+ **Deploy a working example in 5 minutes:**
8
+
9
+ Clone the repository, build the project, then navigate to any example directory and deploy using CDK with your AWS profile and region.
10
+
11
+ ## Core Use Cases
12
+
13
+ ### 1. 📄 Document Processing
14
+
15
+ Serverless document processing pipeline with AI-powered classification, extraction, and workflow orchestration.
16
+
17
+ **Architecture:**
18
+ ```
19
+ S3 Upload → SQS → Step Functions → Bedrock Models → DynamoDB
20
+ ↓ ↓ ↓ ↓ ↓
21
+ [Storage] [Buffer] [Workflow] [AI Processing] [Results]
22
+ ```
23
+
24
+ **Key Features:**
25
+ - **Event-Driven Pipeline**: S3 upload triggers SQS → Step Functions workflow
26
+ - **AI-Powered Processing**: Amazon Bedrock for document classification and extraction
27
+ - **Multi-format Support**: PDF, JPG, PNG document processing
28
+ - **Flexible Workflows**: Base construct with extensible processing steps
29
+ - **State Management**: DynamoDB for workflow state and document metadata
30
+ - **Error Handling**: Dead letter queues and retry mechanisms with observability
31
+
32
+ **Available Constructs:**
33
+
34
+ **BaseDocumentProcessing** - Foundation construct providing:
35
+ - S3 bucket with organized prefixes (raw/, processed/, failed/)
36
+ - SQS queue with configurable visibility timeout and DLQ
37
+ - DynamoDB table for document metadata and workflow state
38
+ - Step Functions workflow with customizable processing steps
39
+ - Built-in observability and monitoring
40
+
41
+ **BedrockDocumentProcessing** - AI-powered document analysis:
42
+ - Document classification using Claude 3.5 Sonnet
43
+ - Entity extraction and content analysis
44
+ - Configurable prompts for classification and extraction
45
+ - Optional enrichment Lambda function integration
46
+ - Automatic workflow state management
47
+
48
+ **AgenticDocumentProcessing** - Multi-agent document workflows:
49
+ - Advanced multi-step processing with agent coordination
50
+ - Complex document understanding and analysis
51
+ - Configurable agent behaviors and processing flows
52
+
53
+ ### 2. 🌐 Frontend Web Applications
54
+
55
+ Static web application hosting with CloudFront distribution and security best practices.
56
+
57
+ **Architecture:**
58
+ ```
59
+ CloudFront → S3 Static Website → Security Headers
60
+ ↓ ↓ ↓
61
+ [Global CDN] [Static Assets] [Security Functions]
62
+ ```
63
+
64
+ **Key Features:**
65
+ - **Global Distribution**: CloudFront CDN for low-latency content delivery
66
+ - **Security Headers**: Automatic injection of security headers via CloudFront functions
67
+ - **SSL/TLS**: Automatic HTTPS with AWS Certificate Manager
68
+ - **Custom Domains**: Support for custom domain names with Route 53 integration
69
+ - **Error Pages**: Custom 404/403 error page handling
70
+ - **Access Logging**: CloudFront access logs for analytics
71
+
72
+ **Available Constructs:**
73
+
74
+ **FrontendConstruct** - Complete static website hosting:
75
+ - S3 bucket configured for static website hosting
76
+ - CloudFront distribution with optimized caching
77
+ - Security headers function for OWASP compliance
78
+ - Optional custom domain and SSL certificate
79
+ - Access logging and monitoring integration
80
+
81
+ ### 3. 📊 Observability & Monitoring
82
+
83
+ Comprehensive monitoring, logging, and alerting for AWS infrastructure with automatic property injection and Lambda Powertools integration.
84
+
85
+ **Features:**
86
+ - **Property Injection**: Automatic observability configuration across AWS services
87
+ - **Lambda Powertools**: Structured logging, metrics, and tracing for Python/Node.js
88
+ - **CloudWatch Integration**: Dashboards, alarms, and custom metrics
89
+ - **X-Ray Tracing**: End-to-end request flow visualization
90
+ - **Bedrock Monitoring**: Specialized observability for Amazon Bedrock workloads
91
+ - **Cost Optimization**: Intelligent log retention and metric filtering
92
+
93
+ **Available Components:**
94
+
95
+ **Property Injectors:**
96
+ - `LambdaObservabilityPropertyInjector` - Auto-enables X-Ray tracing for Lambda functions
97
+ - `StateMachineObservabilityPropertyInjector` - Enables logging for Step Functions
98
+ - `CloudfrontDistributionObservabilityPropertyInjector` - CDN monitoring and logging
99
+
100
+ **Observability Constructs:**
101
+ - `BedrockObservability` - Comprehensive monitoring for Bedrock workloads with log groups, encryption, and data protection
102
+ - `PowertoolsConfig` - Lambda Powertools configuration for structured logging and metrics
103
+ - `Observable` interface - Standardized observability contract for constructs
104
+
105
+ **Data Protection:**
106
+ - `LogGroupDataProtectionProps` - Configurable data protection policies for CloudWatch logs
107
+
108
+ ### 4. 🏗️ Foundation & Framework
109
+
110
+ Core infrastructure components and utilities for building scalable applications.
111
+
112
+ **Available Components:**
113
+
114
+ **Network Foundation:**
115
+ - `Network` - VPC with public/private subnets, NAT gateways, and security groups
116
+ - `AccessLog` - Centralized access logging configuration for AWS services
117
+ - `EventBridgeBroker` - Event-driven architecture with custom EventBridge bus
118
+
119
+ **Utilities:**
120
+ - `DataLoader` - Custom resource for loading initial data into databases and services
121
+ - `LambdaIamUtils` - Utility functions for Lambda IAM role and policy management
122
+ - `DefaultRuntimes` - Standardized Lambda runtime configurations
123
+
124
+ **Lambda Layers:**
125
+ - `DataMasking` - Layer for data masking and PII protection in Lambda functions
126
+
127
+ ## Essential Commands
128
+
129
+ **Build & Deploy:**
130
+
131
+ Build entire project with npx projen build. Deploy with specific profile/region using npx cdk deploy --require-approval never. Update CDK CLI if needed with npm install aws-cdk@latest.
132
+
133
+ **Development:**
134
+
135
+ Run tests with npm test. Run specific test pattern with npm test -- --testPathPattern="document-processing". Generate CDK Nag compliance reports with npm test -- --testPathPattern="nag.test.ts".
136
+
137
+ ## Repository Structure
138
+
139
+ ```
140
+ appmod-usecase-blueprints/
141
+ ├── use-cases/
142
+ │ ├── document-processing/ # Document processing components
143
+ │ │ ├── base-document-processing.ts
144
+ │ │ ├── bedrock-document-processing.ts
145
+ │ │ ├── agentic-document-processing.ts
146
+ │ │ ├── resources/ # Lambda functions
147
+ │ │ └── tests/ # Unit and CDK Nag tests
148
+ │ ├── webapp/ # Web application components
149
+ │ │ ├── frontend-construct.ts
150
+ │ │ └── tests/ # Unit and CDK Nag tests
151
+ │ ├── framework/ # Core infrastructure
152
+ │ │ ├── foundation/ # Network, access logs, EventBridge
153
+ │ │ ├── quickstart/ # Base quickstart patterns
154
+ │ │ └── custom-resource/ # Default runtimes
155
+ │ └── utilities/
156
+ │ ├── observability/ # Monitoring components
157
+ │ ├── lambda_layers/ # Shared Lambda layers
158
+ │ ├── data-loader.ts # Custom resource for data loading
159
+ │ └── lambda-iam-utils.ts # IAM utilities
160
+ ├── examples/ # Ready-to-deploy examples
161
+ │ └── document-processing/
162
+ │ ├── bedrock-document-processing/
163
+ │ ├── agentic-document-processing/
164
+ │ └── doc-processing-fullstack-webapp/
165
+ └── README.md
166
+ ```
167
+
168
+ ## Security & Compliance
169
+
170
+ All components include:
171
+ - **CDK Nag Integration**: Automated security compliance checking
172
+ - **AWS Well-Architected**: Following best practices for security, reliability, performance
173
+ - **Encryption**: At-rest and in-transit encryption by default
174
+ - **IAM Least Privilege**: Minimal required permissions
175
+ - **VPC Isolation**: Private subnets and security groups
176
+
177
+ **Generate Compliance Reports:**
178
+
179
+ Run npm test with testPathPattern="nag.test.ts" to generate reports in cdk.out/*-NagReport.csv
180
+
181
+ ## Examples
182
+
183
+ ### Document Processing
184
+ - **Bedrock Document Processing**: AI-powered document analysis with Claude 3.5 Sonnet
185
+ - **Agentic Document Processing**: Multi-agent document workflows with complex processing
186
+ - **Full-Stack Document Processing Webapp**: Complete document processing application with frontend interface
187
+
188
+ Each example includes deployment scripts, sample files, and comprehensive documentation.
189
+
190
+ ## Key AWS Services
191
+
192
+ - **Compute**: Lambda, ECS Fargate, Step Functions
193
+ - **Storage**: S3, DynamoDB
194
+ - **Database**: RDS (MySQL/PostgreSQL)
195
+ - **Networking**: VPC, CloudFront, Application Load Balancer
196
+ - **AI/ML**: Amazon Bedrock, Textract
197
+ - **Monitoring**: CloudWatch, X-Ray
198
+ - **Security**: KMS, Secrets Manager, IAM
199
+
200
+ ## Contributing
201
+
202
+ 1. **Add New Use Case**: Create directory under `use-cases/`
203
+ 2. **Follow Structure**: Include constructs, tests, and documentation
204
+ 3. **Security First**: All components must pass CDK Nag checks
205
+ 4. **Include Monitoring**: Include monitoring, error handling, and cost optimization
206
+
207
+ ## Disclaimer
208
+ These application solutions are not supported products in their own right, but examples to help our customers use our products from their applications. As our customer, any applications you integrate these examples in should be thoroughly tested, secured, and optimized according to your business's security standards before deploying to production or handling production workloads.
209
+
210
+ ## License
211
+
212
+ Apache License 2.0 - see [LICENSE](./LICENSE) file for details.
@@ -0,0 +1,16 @@
1
+ import { LayerVersion } from 'aws-cdk-lib/aws-lambda';
2
+ import { Construct } from 'constructs';
3
+ import { DocumentProcessingStepType } from './base-document-processing';
4
+ import { BedrockDocumentProcessing, BedrockDocumentProcessingProps } from './bedrock-document-processing';
5
+ export interface AgentProps {
6
+ readonly agentSystemPrompt?: string;
7
+ readonly toolsLocation?: string[];
8
+ readonly lambdaLayers?: LayerVersion[];
9
+ }
10
+ export interface AgenticDocumentProcessingProps extends BedrockDocumentProcessingProps {
11
+ readonly processingAgentParameters?: AgentProps;
12
+ }
13
+ export declare class AgenticDocumentProcessing extends BedrockDocumentProcessing {
14
+ constructor(scope: Construct, id: string, props: AgenticDocumentProcessingProps);
15
+ protected processingStep(): DocumentProcessingStepType;
16
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AgenticDocumentProcessing = void 0;
5
+ const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
6
+ const aws_lambda_python_alpha_1 = require("@aws-cdk/aws-lambda-python-alpha");
7
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
8
+ const aws_iam_1 = require("aws-cdk-lib/aws-iam");
9
+ const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
10
+ const aws_stepfunctions_tasks_1 = require("aws-cdk-lib/aws-stepfunctions-tasks");
11
+ const bedrock_document_processing_1 = require("./bedrock-document-processing");
12
+ const framework_1 = require("../framework");
13
+ const utilities_1 = require("../utilities");
14
+ const powertools_config_1 = require("../utilities/observability/powertools-config");
15
+ class AgenticDocumentProcessing extends bedrock_document_processing_1.BedrockDocumentProcessing {
16
+ constructor(scope, id, props) {
17
+ super(scope, id, props);
18
+ }
19
+ processingStep() {
20
+ const agentProps = this.bedrockDocumentProcessingProps;
21
+ const fmModel = this.bedrockDocumentProcessingProps.processingModelId || bedrock_document_processing_1.BedrockDocumentProcessing.DEFAULT_PROCESSING_MODEL_ID;
22
+ const adjustedModelId = this.bedrockDocumentProcessingProps.useCrossRegionInference ? `${this.crossRegionInferencePrefix}.${fmModel.modelId}` : fmModel.modelId;
23
+ const role = this.generateLambdaRoleForBedrock(fmModel, 'ProcessingAgentLambdaRole');
24
+ role.addToPrincipalPolicy(new aws_iam_1.PolicyStatement({
25
+ effect: aws_iam_1.Effect.ALLOW,
26
+ actions: [
27
+ 's3:ListBucket',
28
+ ],
29
+ resources: [
30
+ this.bucket.bucketArn,
31
+ ],
32
+ }));
33
+ const environmentVariables = {
34
+ MODEL_ID: adjustedModelId,
35
+ INVOKE_TYPE: 'agent',
36
+ ...powertools_config_1.PowertoolsConfig.generateDefaultLambdaConfig(this.bedrockDocumentProcessingProps.enableObservability, this.metricNamespace, this.metricServiceName),
37
+ };
38
+ this.encryptionKey.grantEncryptDecrypt(role);
39
+ if (this.bucketEncryptionKey) {
40
+ this.bucketEncryptionKey.grantEncryptDecrypt(role);
41
+ }
42
+ if (agentProps.processingAgentParameters?.toolsLocation) {
43
+ environmentVariables.TOOLS_CONFIG = JSON.stringify(agentProps.processingAgentParameters?.toolsLocation);
44
+ }
45
+ if (agentProps.processingAgentParameters?.agentSystemPrompt) {
46
+ environmentVariables.SYSTEM_PROMPT = agentProps.processingAgentParameters?.agentSystemPrompt;
47
+ }
48
+ if (agentProps.processingPrompt) {
49
+ environmentVariables.PROMPT = agentProps.processingPrompt;
50
+ }
51
+ const { region, account } = aws_cdk_lib_1.Stack.of(this);
52
+ const generatedLogPermissions = utilities_1.LambdaIamUtils.createLogsPermissions({
53
+ account,
54
+ functionName: 'agentic-idp-processing',
55
+ region,
56
+ scope: this,
57
+ });
58
+ const agenticFunction = new aws_lambda_python_alpha_1.PythonFunction(this, 'ProcessingAgentFunction', {
59
+ functionName: generatedLogPermissions.uniqueFunctionName,
60
+ architecture: aws_lambda_1.Architecture.X86_64,
61
+ entry: `${__dirname}/resources/default-strands-agent`,
62
+ runtime: framework_1.DefaultRuntimes.PYTHON,
63
+ layers: agentProps.processingAgentParameters?.lambdaLayers,
64
+ environment: environmentVariables,
65
+ role,
66
+ timeout: this.bedrockDocumentProcessingProps.stepTimeouts || aws_cdk_lib_1.Duration.minutes(5),
67
+ memorySize: 1024,
68
+ environmentEncryption: this.encryptionKey,
69
+ vpc: this.bedrockDocumentProcessingProps.network ? this.bedrockDocumentProcessingProps.network.vpc : undefined,
70
+ vpcSubnets: this.bedrockDocumentProcessingProps.network ? this.bedrockDocumentProcessingProps.network.applicationSubnetSelection() : undefined,
71
+ });
72
+ for (const statement of generatedLogPermissions.policyStatements) {
73
+ agenticFunction.role?.addToPrincipalPolicy(statement);
74
+ }
75
+ if (this.bedrockDocumentProcessingProps.network) {
76
+ agenticFunction.role?.addToPrincipalPolicy(utilities_1.LambdaIamUtils.generateLambdaVPCPermissions());
77
+ }
78
+ return new aws_stepfunctions_tasks_1.LambdaInvoke(this, 'ProcessingStep', {
79
+ lambdaFunction: agenticFunction,
80
+ resultPath: '$.processingResult',
81
+ resultSelector: {
82
+ 'result.$': '$.Payload.result',
83
+ },
84
+ });
85
+ }
86
+ }
87
+ exports.AgenticDocumentProcessing = AgenticDocumentProcessing;
88
+ _a = JSII_RTTI_SYMBOL_1;
89
+ AgenticDocumentProcessing[_a] = { fqn: "@cdklabs/cdk-appmod-catalog-blueprints.AgenticDocumentProcessing", version: "1.0.0" };
90
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdlbnRpYy1kb2N1bWVudC1wcm9jZXNzaW5nLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdXNlLWNhc2VzL2RvY3VtZW50LXByb2Nlc3NpbmcvYWdlbnRpYy1kb2N1bWVudC1wcm9jZXNzaW5nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsOEVBQWtFO0FBQ2xFLDZDQUE4QztBQUM5QyxpREFBOEQ7QUFDOUQsdURBQW9FO0FBQ3BFLGlGQUFtRTtBQUduRSwrRUFBMEc7QUFDMUcsNENBQStDO0FBQy9DLDRDQUE4QztBQUM5QyxvRkFBZ0Y7QUFZaEYsTUFBYSx5QkFBMEIsU0FBUSx1REFBeUI7SUFDdEUsWUFBWSxLQUFnQixFQUFFLEVBQVUsRUFBRSxLQUFxQztRQUM3RSxLQUFLLENBQUMsS0FBSyxFQUFFLEVBQUUsRUFBRSxLQUFLLENBQUMsQ0FBQztJQUMxQixDQUFDO0lBRVMsY0FBYztRQUN0QixNQUFNLFVBQVUsR0FBRyxJQUFJLENBQUMsOEJBQWdFLENBQUM7UUFDekYsTUFBTSxPQUFPLEdBQUcsSUFBSSxDQUFDLDhCQUE4QixDQUFDLGlCQUFpQixJQUFJLHVEQUF5QixDQUFDLDJCQUEyQixDQUFDO1FBQy9ILE1BQU0sZUFBZSxHQUFHLElBQUksQ0FBQyw4QkFBOEIsQ0FBQyx1QkFBdUIsQ0FBQyxDQUFDLEN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