Skip to content

Commit 0125c66

Browse files
committed
fix(idp_sdk): resolve headless deployment issues for GovCloud regions
1 parent f977cbb commit 0125c66

5 files changed

Lines changed: 47 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ SPDX-License-Identifier: MIT-0
3838

3939
### Fixed
4040

41+
- **Headless deployment fails with `ConfigurationPreset` AllowedValues error and `GraphQLApi.Arn` reference error** — Added `lending-package-sample-govcloud` to the base template AllowedValues and ConfigurationMap, and auto-detect GovCloud region (`us-gov-*`) for headless template transform instead of missing or hardcoded flag. Also added Discovery resources (BlueprintOptimization, MultiDocDiscovery, DiscoveryProcessor, etc.) to headless removal list to fix `GraphQLApi.Arn` unresolved reference error.
42+
4143
- **`delete-documents` fails with DynamoDB errors** — Fixed two bugs in `get_documents_by_batch()`: (1) passing empty `ExpressionAttributeNames={}` when no status filter caused `ValidationException`, and (2) using low-level DynamoDB client type descriptors (`{"S": "..."}`) with the high-level Table resource caused `begins_with` operand type mismatch. Rewrote to use the high-level `Table.scan()` API with `boto3.dynamodb.conditions.Attr`.
4244

4345
## [0.5.4]

lib/idp_cli_pkg/idp_cli/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,11 @@ def deploy(
459459
# Transform
460460
headless_template = os.path.join(tmpdir, "idp-headless.yaml")
461461
client_tmp = IDPClient(region=region)
462+
is_govcloud = region and region.startswith("us-gov-")
462463
transform_result = client_tmp.publish.transform_template_headless(
463464
source_template=local_template,
464465
output_path=headless_template,
465-
update_govcloud_config=True,
466+
update_govcloud_config=is_govcloud,
466467
)
467468
if not transform_result.success:
468469
console.print(

lib/idp_sdk/idp_sdk/_core/template_transform.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,23 @@ def __init__(self, verbose: bool = False):
162162
"DOCUMENTKB",
163163
}
164164

165+
self.discovery_resources: Set[str] = {
166+
"DiscoveryBucket",
167+
"DiscoveryBucketPolicy",
168+
"DiscoveryDLQ",
169+
"DiscoveryQueue",
170+
"DiscoveryTrackingTable",
171+
"DiscoveryProcessorFunction",
172+
"DiscoveryProcessorFunctionLogGroup",
173+
"BlueprintOptimizationFunction",
174+
"BlueprintOptimizationFunctionLogGroup",
175+
"MultiDocDiscoveryPrepareFunction",
176+
"MultiDocDiscoveryPrepareFunctionLogGroup",
177+
"MultiDocDiscoveryStateMachine",
178+
"MultiDocDiscoveryStateMachineRole",
179+
"MULTIDOCDISCOVERYSTACK",
180+
}
181+
165182
self.appsync_dependent_resources: Set[str] = {
166183
"StepFunctionSubscriptionPublisher",
167184
"StepFunctionSubscriptionPublisherLogGroup",
@@ -206,6 +223,8 @@ def __init__(self, verbose: bool = False):
206223
"ExternalMCPAgentsSecretConsoleURL",
207224
"MCPConnectorClientId",
208225
"MCPConnectorClientSecret",
226+
"S3DiscoveryBucketName",
227+
"S3DiscoveryBucketConsoleURL",
209228
}
210229

211230
# ---- Conditions to remove ----
@@ -249,6 +268,7 @@ def all_resources_to_remove(self) -> Set[str]:
249268
| self.agent_resources
250269
| self.hitl_resources
251270
| self.kb_resources
271+
| self.discovery_resources
252272
)
253273

254274
# ---- Public API ----
@@ -729,6 +749,18 @@ def _clean_nested_stack_params(
729749
del stack_params["AppSyncApiArn"]
730750
logger.debug(f"Removed AppSyncApiArn parameter from {stack_name}")
731751

752+
# Remove Discovery-related parameters (resources removed in headless)
753+
for param in [
754+
"DiscoveryBucket",
755+
"DiscoveryTrackingTable",
756+
"DiscoveryBucketName",
757+
"DiscoveryTrackingTableName",
758+
"MultiDocDiscoveryStateMachineArn",
759+
]:
760+
if param in stack_params:
761+
del stack_params[param]
762+
logger.debug(f"Removed {param} parameter from {stack_name}")
763+
732764
# Remove dependencies on GraphQLApi
733765
stack_deps = resources[stack_name].get("DependsOn", [])
734766
if isinstance(stack_deps, list) and "GraphQLApi" in stack_deps:
@@ -803,6 +835,12 @@ def _clean_update_settings_values(self, template: Dict[str, Any]) -> None:
803835
del settings_kvp["AllowedSignUpEmailDomains"]
804836
logger.debug("Removed AllowedSignUpEmailDomains from UpdateSettingsValues")
805837

838+
# Remove Discovery-related settings (resources removed in headless)
839+
for key in ["DiscoveryBucket"]:
840+
if key in settings_kvp:
841+
del settings_kvp[key]
842+
logger.debug(f"Removed {key} from UpdateSettingsValues")
843+
806844
def _clean_cloudfront_policy_statements(
807845
self, template: Dict[str, Any]
808846
) -> Dict[str, Any]:

lib/idp_sdk/idp_sdk/operations/publish.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,13 @@ def build(
149149

150150
# Generate headless template if requested
151151
if headless:
152+
is_govcloud = region and region.startswith("us-gov-")
152153
headless_result = self.transform_template_headless(
153154
source_template=template_path,
154155
output_path=os.path.join(
155156
source_dir, ".aws-sam", "idp-headless.yaml"
156157
),
158+
update_govcloud_config=is_govcloud,
157159
)
158160
if headless_result.success and headless_result.output_path:
159161
headless_template_path = headless_result.output_path

template.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Mappings:
4747
ConfigPath: "rule-validation"
4848
rule-extraction:
4949
ConfigPath: "rule-extraction"
50+
lending-package-sample-govcloud:
51+
ConfigPath: "lending-package-sample-govcloud"
5052

5153
Parameters:
5254
# Authorization params
@@ -85,6 +87,7 @@ Parameters:
8587
Default: "lending-package-sample"
8688
AllowedValues:
8789
- "lending-package-sample"
90+
- "lending-package-sample-govcloud"
8891
- "rvl-cdip"
8992
- "rvl-cdip-with-few-shot-examples"
9093
- "bank-statement-sample"

0 commit comments

Comments
 (0)