From 6df5e12fe3a24e28ec83ccf5b988ddeb2a72fc8f Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 20 Feb 2026 15:40:49 -0500 Subject: [PATCH] Fix CFN response keys: add snake_case aliases + branch_name for SC product GetAtt exact key matches. The SC product template uses snake_case keys (repository_url, pull_request_url, branch_name) but Lambda was returning PascalCase (RepositoryUrl, PullRequestUrl) with no branch_name. Now returns both casings for full compatibility: - PascalCase: RepositoryUrl, PullRequestUrl, RepositoryName - snake_case: repository_url, pull_request_url, repository_name, branch_name Also fixes SC test script product name (eks-terragrunt-eks-repo-creator). --- scripts/test_service_catalog.py | 4 ++-- template_automation/app.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/test_service_catalog.py b/scripts/test_service_catalog.py index c990d56..9229ad7 100755 --- a/scripts/test_service_catalog.py +++ b/scripts/test_service_catalog.py @@ -48,7 +48,7 @@ ACCOUNT_ID = "229685449397" # Service Catalog product details -SC_PRODUCT_NAME = "eks-terragrunt-repo-creator" +SC_PRODUCT_NAME = "eks-terragrunt-eks-repo-creator" SC_ARTIFACT_NAME = "v2.0" # GitHub / EKS defaults used as provisioning parameters @@ -580,7 +580,7 @@ def main() -> None: console.print(Rule("[bold cyan]EKS Terragrunt Repo Generator – Service Catalog Test[/bold cyan]")) console.print(f"[dim]Timestamp : {datetime.now(timezone.utc).isoformat()}[/dim]") console.print(f"[dim]Test repo : [bold]{repo_name}[/bold][/dim]") - console.print(f"[dim]Product : {SC_PRODUCT_NAME} v{SC_ARTIFACT_NAME}[/dim]") + console.print(f"[dim]Product : {SC_PRODUCT_NAME} {SC_ARTIFACT_NAME}[/dim]") console.print(f"[dim]Region : {REGION}[/dim]") console.print(f"[dim]Cleanup : {'yes (terminate after test)' if cleanup else 'no (--no-cleanup)'}[/dim]\n") diff --git a/template_automation/app.py b/template_automation/app.py index 78d9702..2df5d37 100644 --- a/template_automation/app.py +++ b/template_automation/app.py @@ -744,9 +744,14 @@ def lambda_handler(event: dict, context) -> dict: raise # Build response data + # Include both PascalCase (for direct Lambda callers) and snake_case + # (for CloudFormation !GetAtt which uses the exact key names from Data) response_data = { "RepositoryUrl": project["web_url"], - "RepositoryName": cfn_input.project_name + "repository_url": project["web_url"], + "RepositoryName": cfn_input.project_name, + "repository_name": cfn_input.project_name, + "branch_name": config_branch, } # Use pull_request_url for GitHub and merge_request_url for GitLab @@ -756,15 +761,19 @@ def lambda_handler(event: dict, context) -> dict: pr_url = mr['_links']['html']['href'] logger.info(f"[{request_id}] Pull request URL from _links: {pr_url}") response_data["PullRequestUrl"] = pr_url + response_data["pull_request_url"] = pr_url elif mr and 'html_url' in mr: # Some GitHub API versions return html_url directly response_data["PullRequestUrl"] = mr['html_url'] + response_data["pull_request_url"] = mr['html_url'] logger.info(f"[{request_id}] Pull request URL from html_url: {mr['html_url']}") else: logger.warning(f"[{request_id}] Could not extract PR URL from response: {json.dumps(mr, default=str)}") response_data["PullRequestUrl"] = "N/A" + response_data["pull_request_url"] = "N/A" else: response_data["MergeRequestUrl"] = mr.get("web_url", "N/A") + response_data["merge_request_url"] = mr.get("web_url", "N/A") logger.info(f"[{request_id}] Operation completed successfully") logger.info(f"[{request_id}] Response data: {json.dumps(response_data, indent=2)}")