Skip to content

Commit bb0c86b

Browse files
author
EC2 Default User
committed
Merge branch 'feature/template-updates' into develop
2 parents 42ee455 + e33fd30 commit bb0c86b

File tree

2 files changed

+107
-14
lines changed

2 files changed

+107
-14
lines changed

docs/configuration.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,37 @@ The web interface allows real-time configuration updates without stack redeploym
2727

2828
Configuration changes are validated and applied immediately, with rollback capability if issues arise. See [web-ui.md](web-ui.md) for details on using the administration interface.
2929

30+
## Custom Configuration Path
31+
32+
The solution now supports specifying a custom configuration file location via the `CustomConfigPath` CloudFormation parameter. This allows you to use your own configuration files stored in S3 instead of the default configuration library.
33+
34+
### Usage
35+
36+
When deploying the stack, you can specify a custom configuration file:
37+
38+
```yaml
39+
CustomConfigPath: "s3://my-bucket/custom-config/config.yaml"
40+
```
41+
42+
**Key Features:**
43+
- **Override Default Configuration**: When specified, your custom configuration completely replaces the default pattern configuration
44+
- **S3 URI Format**: Accepts standard S3 URI format (e.g., `s3://my-bucket/custom-config/config.yaml`)
45+
- **Least-Privilege Security**: IAM permissions are conditionally granted only to the specific S3 bucket and object you specify
46+
- **All Patterns Supported**: Works with Pattern 1 (BDA), Pattern 2 (Textract + Bedrock), and Pattern 3 (Textract + UDOP + Bedrock)
47+
48+
**Security Benefits:**
49+
- Eliminates wildcard S3 permissions (`arn:aws:s3:::*/*`)
50+
- Conditional IAM access only when CustomConfigPath is specified
51+
- Proper S3 URI to ARN conversion for least-privilege compliance
52+
- Passes security scans with minimal required permissions
53+
54+
**Configuration File Requirements:**
55+
- Must be valid YAML format
56+
- Should include all required sections for your chosen pattern (ocr, classes, classification, extraction, etc.)
57+
- Follow the same structure as the default configuration files in the `config_library` directory
58+
59+
Leave the `CustomConfigPath` parameter empty (default) to use the standard configuration library included with the solution.
60+
3061
## Summarization Configuration
3162

3263
### Enable/Disable Summarization
@@ -100,6 +131,7 @@ Key parameters that can be configured during CloudFormation deployment:
100131
- `WAFAllowedIPv4Ranges`: IP restrictions for web UI access (default: allow all)
101132
- `CloudFrontPriceClass`: Set CloudFront price class for UI distribution
102133
- `CloudFrontAllowedGeos`: Optional geographic restrictions for UI access
134+
- `CustomConfigPath`: Optional S3 URI to a custom configuration file that overrides pattern presets. Leave blank to use selected pattern configuration. Example: s3://my-bucket/custom-config/config.yaml
103135

104136
### Pattern Selection
105137
- `IDPPattern`: Select processing pattern:

template.yaml

Lines changed: 75 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ Parameters:
8686
Description: >-
8787
Built-in IDP workflow patterns - see README for pattern descriptions.
8888
89+
# Custom Configuration Path
90+
91+
CustomConfigPath:
92+
Type: String
93+
Default: ""
94+
Description: >-
95+
S3 URI pointing to your custom configuration YAML file. When provided, this configuration overrides the selected pattern preset and applies to all processing patterns.
96+
Leave blank to use the selected pattern configuration preset. For example s3://my-bucket/custom-config/config.yaml
97+
AllowedPattern: '^(|s3://[a-zA-Z0-9.\\-_]+(/.*)?)$'
98+
ConstraintDescription: Must be empty or a valid S3 URI (e.g., s3://my-bucket/custom-config/config.yaml)
99+
89100
# Pattern 1 Parameters
90101

91102
Pattern1BDAProjectArn:
@@ -100,8 +111,9 @@ Parameters:
100111
AllowedValues:
101112
- "lending-package-sample"
102113
- "default"
103-
Description: Select the configuration preset for Pattern 1. Each configuration contains pre-tuned settings for specific document processing scenarios - see https://github.com/aws-samples/sample-genai-idp/blob/main/config_library/README.md.
104-
114+
Description: >-
115+
Select the configuration preset for Pattern 1. Each configuration contains pre-tuned settings for specific document processing scenarios - see https://github.com/aws-samples/sample-genai-idp/blob/main/config_library/README.md. Note: This selected configuration will be replaced by the Custom Configuration Path if specified.
116+
105117
# Pattern 2 Parameters
106118

107119
Pattern2Configuration:
@@ -113,7 +125,8 @@ Parameters:
113125
- "rvl-cdip-package-sample-with-few-shot-examples"
114126
- "bank-statement-sample"
115127
- "default"
116-
Description: Select the configuration preset for Pattern 2. Each configuration contains pre-tuned settings for specific document processing scenarios - see https://github.com/aws-samples/sample-genai-idp/blob/main/config_library/README.md.
128+
Description: >-
129+
Select the configuration preset for Pattern 2. Each configuration contains pre-tuned settings for specific document processing scenarios see https://github.com/aws-samples/sample-genai-idp/blob/main/config_library/README.md. Note: Custom configuration overrides the selected pattern configuration when provided.
117130
118131
Pattern2CustomClassificationModelARN:
119132
Type: String
@@ -139,8 +152,20 @@ Parameters:
139152
AllowedValues:
140153
- "rvl-cdip-package-sample"
141154
- "default"
142-
Description: Select the configuration preset for Pattern 3. Each configuration contains pre-tuned settings for specific document processing scenarios - see https://github.com/aws-samples/sample-genai-idp/blob/main/config_library/README.md.
143-
155+
Description: >-
156+
Select the configuration preset for Pattern 3. Each configuration contains pre-tuned settings for specific document processing scenarios - see https://github.com/aws-samples/sample-genai-idp/blob/main/config_library/README.md. Note: Custom configuration overrides the selected pattern configuration when provided.
157+
158+
# Custom Configuration Path
159+
160+
CustomConfigPath:
161+
Type: String
162+
Default: ""
163+
Description: >-
164+
S3 URI pointing to your custom configuration YAML file. When provided, this configuration overrides the selected pattern preset and applies to all processing patterns.
165+
Leave blank to use the selected pattern configuration preset. For example s3://my-bucket/custom-config/config.yaml
166+
AllowedPattern: '^(|s3://[a-zA-Z0-9.\\-_]+(/.*)?)$'
167+
ConstraintDescription: Must be empty or a valid S3 URI (e.g., s3://my-bucket/custom-config/config.yaml)
168+
144169
# HITL (A2I) Configuration
145170

146171
EnableHITL:
@@ -442,6 +467,7 @@ Conditions:
442467
ShouldUseDocumentKnowledgeBase: !Condition ShouldCreateDocumentKnowledgeBase
443468
DocumentSectionsCrawlerScheduleEnabled: !Not [!Equals [!Ref DocumentSectionsCrawlerFrequency, "Manual"]]
444469
HasPermissionsBoundary: !Not [!Equals [!Ref PermissionsBoundaryArn, ""]]
470+
HasCustomConfigPath: !Not [!Equals [!Ref CustomConfigPath, ""]]
445471

446472

447473
Metadata:
@@ -472,6 +498,10 @@ Metadata:
472498
Parameters:
473499
- Pattern3Configuration
474500
- Pattern3UDOPModelArtifactPath
501+
- Label:
502+
default: "Custom Configuration"
503+
Parameters:
504+
- CustomConfigPath
475505
- Label:
476506
default: "HITL (A2I) Configuration"
477507
Parameters:
@@ -543,6 +573,8 @@ Metadata:
543573
default: "Existing Private Workforce ARN"
544574
Pattern2Configuration:
545575
default: "Pattern2 - Configuration Preset"
576+
CustomConfigPath:
577+
default: "Custom Configuration Path"
546578
Pattern3UDOPModelArtifactPath:
547579
default: "Pattern3 - UDOP Model Artifact Path"
548580
Pattern3Configuration:
@@ -846,9 +878,12 @@ Resources:
846878
AppSyncApiUrl: !GetAtt GraphQLApi.GraphQLUrl
847879
AppSyncApiArn: !GetAtt GraphQLApi.Arn
848880
EnableHITL: !Ref EnableHITL
849-
ConfigurationDefaultS3Uri: !Sub
850-
- "s3://${ConfigurationBucket}/config_library/pattern-1/${ConfigPath}/config.yaml"
851-
- ConfigPath: !FindInMap [Pattern1ConfigurationMap, !Ref Pattern1Configuration, ConfigPath]
881+
ConfigurationDefaultS3Uri: !If
882+
- HasCustomConfigPath
883+
- !Ref CustomConfigPath
884+
- !Sub
885+
- "s3://${ConfigurationBucket}/config_library/pattern-1/${ConfigPath}/config.yaml"
886+
- ConfigPath: !FindInMap [Pattern1ConfigurationMap, !Ref Pattern1Configuration, ConfigPath]
852887
ConfigLibraryHash: "<CONFIG_LIBRARY_HASH_TOKEN>"
853888
PermissionsBoundaryArn: !Ref PermissionsBoundaryArn
854889
SageMakerA2IReviewPortalURL: !If
@@ -884,9 +919,12 @@ Resources:
884919
AppSyncApiUrl: !GetAtt GraphQLApi.GraphQLUrl
885920
AppSyncApiArn: !GetAtt GraphQLApi.Arn
886921
ConfigurationTable: !Ref ConfigurationTable
887-
ConfigurationDefaultS3Uri: !Sub
888-
- "s3://${ConfigurationBucket}/config_library/pattern-2/${ConfigPath}/config.yaml"
889-
- ConfigPath: !FindInMap [Pattern2ConfigurationMap, !Ref Pattern2Configuration, ConfigPath]
922+
ConfigurationDefaultS3Uri: !If
923+
- HasCustomConfigPath
924+
- !Ref CustomConfigPath
925+
- !Sub
926+
- "s3://${ConfigurationBucket}/config_library/pattern-2/${ConfigPath}/config.yaml"
927+
- ConfigPath: !FindInMap [Pattern2ConfigurationMap, !Ref Pattern2Configuration, ConfigPath]
890928
ConfigLibraryHash: "<CONFIG_LIBRARY_HASH_TOKEN>"
891929
EnableHITL: !Ref EnableHITL
892930
SageMakerA2IReviewPortalURL: !If
@@ -922,9 +960,12 @@ Resources:
922960
AppSyncApiUrl: !GetAtt GraphQLApi.GraphQLUrl
923961
AppSyncApiArn: !GetAtt GraphQLApi.Arn
924962
ConfigurationTable: !Ref ConfigurationTable
925-
ConfigurationDefaultS3Uri: !Sub
926-
- "s3://${ConfigurationBucket}/config_library/pattern-3/${ConfigPath}/config.yaml"
927-
- ConfigPath: !FindInMap [Pattern3ConfigurationMap, !Ref Pattern3Configuration, ConfigPath]
963+
ConfigurationDefaultS3Uri: !If
964+
- HasCustomConfigPath
965+
- !Ref CustomConfigPath
966+
- !Sub
967+
- "s3://${ConfigurationBucket}/config_library/pattern-3/${ConfigPath}/config.yaml"
968+
- ConfigPath: !FindInMap [Pattern3ConfigurationMap, !Ref Pattern3Configuration, ConfigPath]
928969
ConfigLibraryHash: "<CONFIG_LIBRARY_HASH_TOKEN>"
929970
EnableHITL: !Ref EnableHITL
930971
SageMakerA2IReviewPortalURL: !If
@@ -2011,6 +2052,26 @@ Resources:
20112052
- !Sub "arn:aws:s3:::<ARTIFACT_BUCKET_TOKEN>/<ARTIFACT_PREFIX_TOKEN>/*"
20122053
- !Sub "arn:aws:s3:::${ConfigurationBucket}"
20132054
- !Sub "arn:aws:s3:::${ConfigurationBucket}/*"
2055+
# Allow reading user-supplied config file only if CustomConfigPath is specified
2056+
- !If
2057+
- HasCustomConfigPath
2058+
- Effect: Allow
2059+
Action:
2060+
- "s3:GetObject"
2061+
Resource: !Sub
2062+
- "arn:aws:s3:::${Path}"
2063+
- Path: !Select [1, !Split ["s3://", !Ref CustomConfigPath]]
2064+
- !Ref AWS::NoValue
2065+
# Allow listing the specific bucket containing the custom config file
2066+
- !If
2067+
- HasCustomConfigPath
2068+
- Effect: Allow
2069+
Action:
2070+
- "s3:ListBucket"
2071+
Resource: !Sub
2072+
- "arn:aws:s3:::${BucketName}"
2073+
- BucketName: !Select [0, !Split ["/", !Select [1, !Split ["s3://", !Ref CustomConfigPath]]]]
2074+
- !Ref AWS::NoValue
20142075

20152076
UpdateConfigurationFunctionLogGroup:
20162077
Type: AWS::Logs::LogGroup

0 commit comments

Comments
 (0)