@@ -145,6 +145,11 @@ def deploy_and_test_pattern(stack_prefix, pattern_config, admin_email, template_
145145 run_command (cmd )
146146 print (f"[{ pattern_name } ] ✅ Inference completed" )
147147
148+ # Wait for results to propagate to S3
149+ print (f"[{ pattern_name } ] Waiting 10 seconds for results to propagate..." )
150+ import time
151+ time .sleep (10 )
152+
148153 # Step 4: Download and verify results
149154 print (f"[{ pattern_name } ] Step 4: Downloading results..." )
150155 results_dir = f"/tmp/results-{ pattern_suffix } "
@@ -239,6 +244,10 @@ def get_codebuild_logs():
239244 if not build_id :
240245 return "CodeBuild logs not available (not running in CodeBuild)"
241246
247+ # Wait for logs to propagate to CloudWatch
248+ import time
249+ time .sleep (10 )
250+
242251 # Extract log group and stream from build ID
243252 log_group = f"/aws/codebuild/{ build_id .split (':' )[0 ]} "
244253 log_stream = build_id .split (':' )[- 1 ]
@@ -275,7 +284,15 @@ def generate_publish_failure_summary(publish_error):
275284 Build Logs:
276285 { get_codebuild_logs ()}
277286
278- ANALYZE THE LOGS FOR: npm ci errors, package-lock.json sync issues, missing @esbuild packages, UI build failures
287+ ANALYZE THE LOGS FOR ALL ERROR TYPES:
288+ - Python linting/formatting errors (ruff check failed, code formatting check failed)
289+ - Python syntax errors (py_compile failures, SyntaxError, IndentationError)
290+ - UI build failures (npm ci errors, package-lock.json sync issues, missing @esbuild packages)
291+ - AWS/Infrastructure errors (S3 access denied, CloudFormation validation failed, SAM build/package failures)
292+ - Missing prerequisites (aws/sam not found, version requirements not met)
293+ - File system errors (missing files, permission denied, disk space issues)
294+ - Dependency issues (pip install failures, missing Python packages, Docker build errors)
295+ - Lambda validation failures (missing idp_common in builds, import test failures)
279296
280297 Create a summary focused on BUILD/PUBLISH issues with bullet points:
281298
@@ -287,16 +304,17 @@ def generate_publish_failure_summary(publish_error):
287304 • Template Publish: FAILED - S3 access denied
288305
289306 🔍 Technical Root Cause:
290- • Extract exact npm/pip error messages from logs
291- • Identify specific missing packages or version conflicts
307+ • Extract exact error messages from logs (ruff, npm, pip, aws, sam errors)
308+ • Identify specific missing packages, version conflicts, or permission issues
292309 • Focus on build-time errors, not deployment errors
293- • Check AWS credentials and S3 bucket permissions
310+ • Check AWS credentials, S3 bucket permissions, and file access issues
294311
295312 💡 Fix Commands:
296- • Run: cd src/ui && rm package-lock.json && npm install
297- • Check AWS profile: aws configure list --profile <name>
298- • Verify S3 access: aws s3 ls s3://bucket-name --profile <name>
299- • Update package-lock.json and commit changes
313+ • Provide specific commands based on actual error found
314+ • For linting: run ruff format . && ruff check --fix .
315+ • For npm: cd src/ui && rm package-lock.json && npm install
316+ • For AWS S3: aws s3 ls s3://bucket-name to test access
317+ • For permissions: chmod +x script.sh or check IAM policies
300318
301319 Keep each bullet point under 75 characters. Use sub-bullets for details.
302320
@@ -426,42 +444,56 @@ def generate_deployment_summary(deployment_results, stack_prefix, template_url):
426444 # Initialize Bedrock client
427445 bedrock = boto3 .client ('bedrock-runtime' )
428446
429- # Create prompt for Bedrock with CodeBuild logs first
447+ # Create prompt for Bedrock with structured analysis
430448 prompt = dedent (f"""
431- You are an AWS deployment analyst. Analyze deployment failures and determine root cause .
449+ You are an AWS deployment analyst. Analyze deployment results and determine appropriate response .
432450
433451 Deployment Information:
434452 - Stack Prefix: { stack_prefix }
435453 - Template URL: { template_url }
436454 - Total Patterns: { len (deployment_results )}
437455
438- Pattern Results:
456+ Pattern Results (ANALYZE THIS FIRST) :
439457 { json .dumps (deployment_results , indent = 2 )}
440458
441- CodeBuild Logs:
459+ CodeBuild Logs (may be interleaved due to parallel execution) :
442460 { deployment_logs }
443461
444- FIRST: Analyze CodeBuild logs for clear error messages. If root cause is unclear from CodeBuild logs, respond with "NEED_CF_LOGS" and list the failed stack names.
462+ STEP 1: Check Pattern Results for failure classification:
463+ - If ALL patterns have "success": true → SUCCESS CASE
464+ - If error contains "No result file found" or "verification failed" → SMOKE TEST FAILURE
465+ - If error contains "deployment failed" or "CREATE_FAILED" or "timeout" → INFRASTRUCTURE FAILURE
466+
467+ STEP 2: Respond based on classification:
468+
469+ FOR SUCCESS CASE (all patterns successful):
470+ 🚀 DEPLOYMENT RESULTS
471+
472+ 📋 Pattern Status:
473+ • Pattern 1 - BDA: SUCCESS - Stack deployed and tested successfully
474+ • Pattern 2 - OCR: SUCCESS - Stack deployed and tested successfully
445475
446- IF root cause is clear from CodeBuild logs, create summary:
476+ FOR INFRASTRUCTURE FAILURE:
477+ Respond ONLY with: "NEED_CF_LOGS: stack1,stack2" (list failed stack names)
447478
479+ FOR SMOKE TEST FAILURE:
448480 🚀 DEPLOYMENT RESULTS
449481
450482 📋 Pattern Status:
451- • Pattern 1 - BDA : FAILED - Stack deployment timeout (300s)
452- • Pattern 2 - OCR : SUCCESS - Stack deployed successfully (120s)
483+ • [ Pattern Name] : FAILED - [specific failure reason from Pattern Results]
484+ • [ Pattern Name] : SUCCESS - Stack deployed and tested successfully
453485
454486 🔍 Root Cause Analysis:
455- • Extract specific error messages from CodeBuild logs
456- • Focus on deployment failures, timeout errors, permission issues
457- • Check for CLI command failures and their error messages
487+ • Extract specific error from Pattern Results
488+ • Focus on post- deployment verification issues
489+ • Identify timing, file path, or result validation problems
458490
459491 💡 Fix Commands:
460- • Provide specific commands to resolve identified issues
492+ • Provide specific commands to resolve verification issues
461493
462494 Keep each bullet point under 75 characters.
463495
464- IMPORTANT: If CodeBuild logs don't show clear root cause, respond ONLY with "NEED_CF_LOGS: stack1,stack2"
496+ IMPORTANT: Only use NEED_CF_LOGS for actual infrastructure/deployment failures, NOT for smoke test failures.
465497 """ )
466498
467499 # Call Bedrock API
0 commit comments