Skip to content

Commit 81242ad

Browse files
committed
Merge branch 'fix/govcloud-principals' into 'develop'
GovCloud Compatibility - Hardcoded Service Domain References See merge request genaiic-reusable-assets/engagement-artifacts/genaiic-idp-accelerator!294
2 parents 11f1d95 + 2ac1821 commit 81242ad

File tree

9 files changed

+57
-75
lines changed

9 files changed

+57
-75
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ SPDX-License-Identifier: MIT-0
1212
- **Integrated Workflow**: Development setup combining Windows tools (VS Code, browsers) with native Linux environment
1313
- **Target Use Cases**: Windows developers needing Linux compatibility without Docker Desktop or VM overhead
1414

15+
### Fixed
16+
- **GovCloud Compatibility - Hardcoded Service Domain References**
17+
- Fixed hardcoded `amazonaws.com` references in CloudFormation templates that prevented GovCloud deployment
18+
- Updated all service principals and endpoints to use dynamic `${AWS::URLSuffix}` expressions for automatic region-based resolution
19+
- **Templates Updated**: `template.yaml` (main template), `patterns/pattern-3/sagemaker_classifier_endpoint.yaml`
20+
- **Services Fixed**: EventBridge, Cognito, SageMaker, ECR, CloudFront, CodeBuild, AppSync, Lambda, DynamoDB, CloudWatch Logs, Glue
21+
- Resolves GitHub Issue #50 - templates now deploy correctly in both standard AWS and GovCloud regions
22+
1523

1624
## [0.3.14]
1725

memory-bank/activeContext.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
## Current Task Status
44

5-
**Feature Implementation**: ✅ **COMPLETED** - GovCloud Template Generation System
5+
**Feature Implementation**: ✅ **COMPLETED** - Service Principal GovCloud Compatibility Updates
66

77
## Feature Overview
88

9-
Successfully created a comprehensive GovCloud-compatible version of the GenAI IDP Accelerator that addresses both key requirements:
9+
Successfully updated all CloudFormation templates to replace hardcoded AWS service principals with dynamic expressions for GovCloud compatibility:
1010

11-
1. **ARN Partition Updates**: All templates now use `arn:${AWS::Partition}:` for GovCloud compatibility
12-
2. **Stripped-Down Template**: Created generation script that removes UI components for headless operation
11+
1. **Service Principal Updates**: All templates now use `!Sub "<service>.${AWS::URLSuffix}"` for GovCloud compatibility
12+
2. **Template Fixes**: Fixed YAML validation errors and duplicate parameter issues
13+
3. **Comprehensive Coverage**: Updated all templates in main, options, and patterns directories
1314

1415
## Implementation Summary
1516

options/bda-lending-project/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Resources:
5757
Statement:
5858
- Effect: Allow
5959
Principal:
60-
Service: lambda.amazonaws.com
60+
Service: !Sub "lambda.${AWS::URLSuffix}"
6161
Action: sts:AssumeRole
6262
ManagedPolicyArns:
6363
- !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"

options/bedrockkb/template.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ Resources:
400400
- Effect: Allow
401401
Principal:
402402
Service:
403-
- lambda.amazonaws.com
403+
- !Sub "lambda.${AWS::URLSuffix}"
404404
Action:
405405
- sts:AssumeRole
406406
PermissionsBoundary: !If [HasPermissionsBoundary, !Ref PermissionsBoundaryArn, !Ref AWS::NoValue]
@@ -524,7 +524,7 @@ Resources:
524524
- Effect: Allow
525525
Principal:
526526
Service:
527-
- bedrock.amazonaws.com
527+
- !Sub "bedrock.${AWS::URLSuffix}"
528528
Action:
529529
- sts:AssumeRole
530530
Condition:
@@ -725,7 +725,7 @@ Resources:
725725
Statement:
726726
- Effect: Allow
727727
Principal:
728-
Service: lambda.amazonaws.com
728+
Service: !Sub "lambda.${AWS::URLSuffix}"
729729
Action: sts:AssumeRole
730730
ManagedPolicyArns:
731731
- !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
@@ -831,7 +831,7 @@ Resources:
831831
Statement:
832832
- Effect: Allow
833833
Principal:
834-
Service: scheduler.amazonaws.com
834+
Service: !Sub "scheduler.${AWS::URLSuffix}"
835835
Action: sts:AssumeRole
836836
PermissionsBoundary: !If [HasPermissionsBoundary, !Ref PermissionsBoundaryArn, !Ref AWS::NoValue]
837837
Policies:

patterns/pattern-1/template.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ Resources:
854854
Properties:
855855
Action: lambda:InvokeFunction
856856
FunctionName: !Ref BDACompletionFunction
857-
Principal: events.amazonaws.com
857+
Principal: !Sub "events.${AWS::URLSuffix}"
858858
SourceArn: !GetAtt BDAEventRule.Arn
859859

860860
# DynamoDB Table for BDA process records metadata
@@ -945,7 +945,7 @@ Resources:
945945
Statement:
946946
- Effect: Allow
947947
Principal:
948-
Service: lambda.amazonaws.com
948+
Service: !Sub "lambda.${AWS::URLSuffix}"
949949
Action: sts:AssumeRole
950950
ManagedPolicyArns:
951951
- !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
@@ -1119,7 +1119,7 @@ Resources:
11191119
Properties:
11201120
FunctionName: !Ref HITLProcessLambdaFunction
11211121
Action: 'lambda:InvokeFunction'
1122-
Principal: 'events.amazonaws.com'
1122+
Principal: !Sub "events.${AWS::URLSuffix}"
11231123
SourceArn: !GetAtt HITLEventRule.Arn
11241124

11251125

patterns/pattern-2/template.yaml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,6 @@ Parameters:
9191
- "false"
9292
Description: "Enable Human In The Loop (A2I) for document review"
9393

94-
IsPattern2HITLEnabled:
95-
Type: String
96-
Default: "false"
97-
AllowedValues:
98-
- "true"
99-
- "false"
100-
Description: "Pattern-2 specific HITL enablement flag"
101-
10294
SageMakerA2IReviewPortalURL:
10395
Type: String
10496
Default: ""
@@ -130,8 +122,6 @@ Conditions:
130122
HasPermissionsBoundary: !Not [!Equals [!Ref PermissionsBoundaryArn, ""]]
131123
IsHITLEnabled: !Equals [!Ref EnableHITL, "true"]
132124
HasAppSyncApi: !Not [!Equals [!Ref AppSyncApiArn, ""]]
133-
IsPattern2HITLEnabled: !Equals [!Ref IsPattern2HITLEnabled, "true"]
134-
135125

136126
Resources:
137127

@@ -1371,12 +1361,15 @@ Resources:
13711361
- kms:GenerateDataKey*
13721362
- kms:DescribeKey
13731363
Resource: !Ref CustomerManagedEncryptionKeyArn
1374-
# AppSync permissions for updating document status
1375-
- Effect: Allow
1376-
Action:
1377-
- appsync:GraphQL
1378-
Resource:
1379-
- !Sub "${AppSyncApiArn}/types/Mutation/*"
1364+
# AppSync permissions for updating document status (only if AppSync API is available)
1365+
- !If
1366+
- HasAppSyncApi
1367+
- Effect: Allow
1368+
Action:
1369+
- appsync:GraphQL
1370+
Resource:
1371+
- !Sub "${AppSyncApiArn}/types/Mutation/*"
1372+
- !Ref AWS::NoValue
13801373

13811374
HITLWaitFunctionLogGroup:
13821375
Type: AWS::Logs::LogGroup
@@ -1486,7 +1479,7 @@ Resources:
14861479
Statement:
14871480
- Effect: Allow
14881481
Principal:
1489-
Service: lambda.amazonaws.com
1482+
Service: !Sub "lambda.${AWS::URLSuffix}"
14901483
Action: sts:AssumeRole
14911484
ManagedPolicyArns:
14921485
- !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
@@ -1546,7 +1539,7 @@ Resources:
15461539
Properties:
15471540
FunctionName: !Ref HITLProcessLambdaFunction
15481541
Action: 'lambda:InvokeFunction'
1549-
Principal: 'events.amazonaws.com'
1542+
Principal: !Sub "events.${AWS::URLSuffix}"
15501543
SourceArn: !GetAtt HITLEventRule.Arn
15511544

15521545
SummarizationFunction:

patterns/pattern-3/sagemaker_classifier_endpoint.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Resources:
8686
- Effect: Allow
8787
Principal:
8888
Service:
89-
- sagemaker.amazonaws.com
89+
- !Sub "sagemaker.${AWS::URLSuffix}"
9090
Action:
9191
- sts:AssumeRole
9292
ManagedPolicyArns:
@@ -127,7 +127,7 @@ Resources:
127127
Properties:
128128
ExecutionRoleArn: !GetAtt UDOPExecutionRole.Arn
129129
PrimaryContainer:
130-
Image: !Sub 763104351884.dkr.ecr.${AWS::Region}.amazonaws.com/pytorch-inference:2.1.0-gpu-py310
130+
Image: !Sub "763104351884.dkr.ecr.${AWS::Region}.${AWS::URLSuffix}/pytorch-inference:2.1.0-gpu-py310"
131131
ModelDataUrl: !Ref UDOPModelArtifactPath
132132
Environment:
133133
SAGEMAKER_PROGRAM: inference.py
@@ -163,7 +163,7 @@ Resources:
163163
MaxCapacity: !Ref MaxInstanceCount
164164
MinCapacity: !Ref MinInstanceCount
165165
ResourceId: !Sub endpoint/${UDOPEndpoint.EndpointName}/variant/AllTraffic
166-
RoleARN: !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/aws-service-role/sagemaker.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_SageMakerEndpoint"
166+
RoleARN: !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/aws-service-role/sagemaker.application-autoscaling.${AWS::URLSuffix}/AWSServiceRoleForApplicationAutoScaling_SageMakerEndpoint"
167167
ScalableDimension: sagemaker:variant:DesiredInstanceCount
168168
ServiceNamespace: sagemaker
169169

scripts/generate_govcloud_template.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ def __init__(self, verbose: bool = False):
194194
'WebUITestEnvFile',
195195
'SageMakerA2IReviewPortalURL',
196196
'LabelingConsoleURL',
197-
'ExternalMCPAgentsSecretName'
197+
'ExternalMCPAgentsSecretName',
198+
'PrivateWorkteamArn'
198199
}
199200

200201
def setup_logging(self):

0 commit comments

Comments
 (0)