runbooks 0.7.7__py3-none-any.whl → 0.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. runbooks/__init__.py +1 -1
  2. runbooks/base.py +2 -2
  3. runbooks/cfat/README.md +12 -1
  4. runbooks/cfat/__init__.py +8 -4
  5. runbooks/cfat/assessment/collectors.py +171 -14
  6. runbooks/cfat/assessment/compliance.py +546 -522
  7. runbooks/cfat/assessment/runner.py +129 -10
  8. runbooks/cfat/models.py +6 -2
  9. runbooks/common/__init__.py +152 -0
  10. runbooks/common/accuracy_validator.py +1039 -0
  11. runbooks/common/context_logger.py +440 -0
  12. runbooks/common/cross_module_integration.py +594 -0
  13. runbooks/common/enhanced_exception_handler.py +1108 -0
  14. runbooks/common/enterprise_audit_integration.py +634 -0
  15. runbooks/common/logger.py +14 -0
  16. runbooks/common/mcp_integration.py +539 -0
  17. runbooks/common/performance_monitor.py +387 -0
  18. runbooks/common/profile_utils.py +216 -0
  19. runbooks/common/rich_utils.py +622 -0
  20. runbooks/enterprise/__init__.py +68 -0
  21. runbooks/enterprise/error_handling.py +411 -0
  22. runbooks/enterprise/logging.py +439 -0
  23. runbooks/enterprise/multi_tenant.py +583 -0
  24. runbooks/feedback/user_feedback_collector.py +440 -0
  25. runbooks/finops/README.md +129 -14
  26. runbooks/finops/__init__.py +22 -3
  27. runbooks/finops/account_resolver.py +279 -0
  28. runbooks/finops/accuracy_cross_validator.py +638 -0
  29. runbooks/finops/aws_client.py +721 -36
  30. runbooks/finops/budget_integration.py +313 -0
  31. runbooks/finops/cli.py +90 -33
  32. runbooks/finops/cost_processor.py +211 -37
  33. runbooks/finops/dashboard_router.py +900 -0
  34. runbooks/finops/dashboard_runner.py +1334 -399
  35. runbooks/finops/embedded_mcp_validator.py +288 -0
  36. runbooks/finops/enhanced_dashboard_runner.py +526 -0
  37. runbooks/finops/enhanced_progress.py +327 -0
  38. runbooks/finops/enhanced_trend_visualization.py +423 -0
  39. runbooks/finops/finops_dashboard.py +41 -0
  40. runbooks/finops/helpers.py +639 -323
  41. runbooks/finops/iam_guidance.py +400 -0
  42. runbooks/finops/markdown_exporter.py +466 -0
  43. runbooks/finops/multi_dashboard.py +1502 -0
  44. runbooks/finops/optimizer.py +396 -395
  45. runbooks/finops/profile_processor.py +2 -2
  46. runbooks/finops/runbooks.inventory.organizations_discovery.log +0 -0
  47. runbooks/finops/runbooks.security.report_generator.log +0 -0
  48. runbooks/finops/runbooks.security.run_script.log +0 -0
  49. runbooks/finops/runbooks.security.security_export.log +0 -0
  50. runbooks/finops/service_mapping.py +195 -0
  51. runbooks/finops/single_dashboard.py +710 -0
  52. runbooks/finops/tests/__init__.py +19 -0
  53. runbooks/finops/tests/results_test_finops_dashboard.xml +1 -0
  54. runbooks/finops/tests/run_comprehensive_tests.py +421 -0
  55. runbooks/finops/tests/run_tests.py +305 -0
  56. runbooks/finops/tests/test_finops_dashboard.py +705 -0
  57. runbooks/finops/tests/test_integration.py +477 -0
  58. runbooks/finops/tests/test_performance.py +380 -0
  59. runbooks/finops/tests/test_performance_benchmarks.py +500 -0
  60. runbooks/finops/tests/test_reference_images_validation.py +867 -0
  61. runbooks/finops/tests/test_single_account_features.py +715 -0
  62. runbooks/finops/tests/validate_test_suite.py +220 -0
  63. runbooks/finops/types.py +1 -1
  64. runbooks/hitl/enhanced_workflow_engine.py +725 -0
  65. runbooks/inventory/README.md +12 -1
  66. runbooks/inventory/artifacts/scale-optimize-status.txt +12 -0
  67. runbooks/inventory/collectors/aws_comprehensive.py +192 -185
  68. runbooks/inventory/collectors/enterprise_scale.py +281 -0
  69. runbooks/inventory/core/collector.py +299 -12
  70. runbooks/inventory/list_ec2_instances.py +21 -20
  71. runbooks/inventory/list_ssm_parameters.py +31 -3
  72. runbooks/inventory/organizations_discovery.py +1315 -0
  73. runbooks/inventory/rich_inventory_display.py +360 -0
  74. runbooks/inventory/run_on_multi_accounts.py +32 -16
  75. runbooks/inventory/runbooks.security.report_generator.log +0 -0
  76. runbooks/inventory/runbooks.security.run_script.log +0 -0
  77. runbooks/inventory/vpc_flow_analyzer.py +1030 -0
  78. runbooks/main.py +4171 -1615
  79. runbooks/metrics/dora_metrics_engine.py +1293 -0
  80. runbooks/monitoring/performance_monitor.py +433 -0
  81. runbooks/operate/README.md +394 -0
  82. runbooks/operate/__init__.py +2 -2
  83. runbooks/operate/base.py +291 -11
  84. runbooks/operate/deployment_framework.py +1032 -0
  85. runbooks/operate/deployment_validator.py +853 -0
  86. runbooks/operate/dynamodb_operations.py +10 -6
  87. runbooks/operate/ec2_operations.py +321 -11
  88. runbooks/operate/executive_dashboard.py +779 -0
  89. runbooks/operate/mcp_integration.py +750 -0
  90. runbooks/operate/nat_gateway_operations.py +1120 -0
  91. runbooks/operate/networking_cost_heatmap.py +685 -0
  92. runbooks/operate/privatelink_operations.py +940 -0
  93. runbooks/operate/s3_operations.py +10 -6
  94. runbooks/operate/vpc_endpoints.py +644 -0
  95. runbooks/operate/vpc_operations.py +1038 -0
  96. runbooks/remediation/README.md +489 -13
  97. runbooks/remediation/__init__.py +2 -2
  98. runbooks/remediation/acm_remediation.py +1 -1
  99. runbooks/remediation/base.py +1 -1
  100. runbooks/remediation/cloudtrail_remediation.py +1 -1
  101. runbooks/remediation/cognito_remediation.py +1 -1
  102. runbooks/remediation/commons.py +8 -4
  103. runbooks/remediation/dynamodb_remediation.py +1 -1
  104. runbooks/remediation/ec2_remediation.py +1 -1
  105. runbooks/remediation/ec2_unattached_ebs_volumes.py +1 -1
  106. runbooks/remediation/kms_enable_key_rotation.py +1 -1
  107. runbooks/remediation/kms_remediation.py +1 -1
  108. runbooks/remediation/lambda_remediation.py +1 -1
  109. runbooks/remediation/multi_account.py +1 -1
  110. runbooks/remediation/rds_remediation.py +1 -1
  111. runbooks/remediation/s3_block_public_access.py +1 -1
  112. runbooks/remediation/s3_enable_access_logging.py +1 -1
  113. runbooks/remediation/s3_encryption.py +1 -1
  114. runbooks/remediation/s3_remediation.py +1 -1
  115. runbooks/remediation/vpc_remediation.py +475 -0
  116. runbooks/security/ENTERPRISE_SECURITY_FRAMEWORK.md +506 -0
  117. runbooks/security/README.md +12 -1
  118. runbooks/security/__init__.py +166 -33
  119. runbooks/security/compliance_automation.py +634 -0
  120. runbooks/security/compliance_automation_engine.py +1021 -0
  121. runbooks/security/enterprise_security_framework.py +931 -0
  122. runbooks/security/enterprise_security_policies.json +293 -0
  123. runbooks/security/integration_test_enterprise_security.py +879 -0
  124. runbooks/security/module_security_integrator.py +641 -0
  125. runbooks/security/report_generator.py +10 -0
  126. runbooks/security/run_script.py +27 -5
  127. runbooks/security/security_baseline_tester.py +153 -27
  128. runbooks/security/security_export.py +456 -0
  129. runbooks/sre/README.md +472 -0
  130. runbooks/sre/__init__.py +33 -0
  131. runbooks/sre/mcp_reliability_engine.py +1049 -0
  132. runbooks/sre/performance_optimization_engine.py +1032 -0
  133. runbooks/sre/reliability_monitoring_framework.py +1011 -0
  134. runbooks/validation/__init__.py +10 -0
  135. runbooks/validation/benchmark.py +489 -0
  136. runbooks/validation/cli.py +368 -0
  137. runbooks/validation/mcp_validator.py +797 -0
  138. runbooks/vpc/README.md +478 -0
  139. runbooks/vpc/__init__.py +38 -0
  140. runbooks/vpc/config.py +212 -0
  141. runbooks/vpc/cost_engine.py +347 -0
  142. runbooks/vpc/heatmap_engine.py +605 -0
  143. runbooks/vpc/manager_interface.py +649 -0
  144. runbooks/vpc/networking_wrapper.py +1289 -0
  145. runbooks/vpc/rich_formatters.py +693 -0
  146. runbooks/vpc/tests/__init__.py +5 -0
  147. runbooks/vpc/tests/conftest.py +356 -0
  148. runbooks/vpc/tests/test_cli_integration.py +530 -0
  149. runbooks/vpc/tests/test_config.py +458 -0
  150. runbooks/vpc/tests/test_cost_engine.py +479 -0
  151. runbooks/vpc/tests/test_networking_wrapper.py +512 -0
  152. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/METADATA +175 -65
  153. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/RECORD +157 -60
  154. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/entry_points.txt +1 -1
  155. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/WHEEL +0 -0
  156. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/licenses/LICENSE +0 -0
  157. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,649 @@
1
+ """
2
+ VPC Manager Interface - Business User Support Module
3
+
4
+ This module provides business-friendly interfaces and utilities specifically
5
+ designed for non-technical managers and executives using the VPC cost
6
+ optimization dashboard.
7
+ """
8
+
9
+ import json
10
+ import logging
11
+ from dataclasses import asdict, dataclass
12
+ from datetime import datetime, timedelta
13
+ from enum import Enum
14
+ from pathlib import Path
15
+ from typing import Any, Dict, List, Optional, Tuple
16
+
17
+ import pandas as pd
18
+ from rich.console import Console
19
+ from rich.panel import Panel
20
+ from rich.progress import Progress, SpinnerColumn, TextColumn
21
+ from rich.table import Table
22
+
23
+ logger = logging.getLogger(__name__)
24
+
25
+
26
+ class BusinessPriority(Enum):
27
+ """Business priority levels for manager decision making"""
28
+
29
+ CRITICAL = "Critical"
30
+ HIGH = "High"
31
+ MEDIUM = "Medium"
32
+ LOW = "Low"
33
+
34
+
35
+ class RiskLevel(Enum):
36
+ """Risk assessment levels for business decisions"""
37
+
38
+ MINIMAL = "Minimal"
39
+ LOW = "Low"
40
+ MEDIUM = "Medium"
41
+ HIGH = "High"
42
+
43
+
44
+ @dataclass
45
+ class BusinessRecommendation:
46
+ """Business-focused recommendation structure"""
47
+
48
+ title: str
49
+ executive_summary: str
50
+ monthly_savings: float
51
+ annual_impact: float
52
+ implementation_timeline: str
53
+ business_priority: BusinessPriority
54
+ risk_level: RiskLevel
55
+ resource_requirements: List[str]
56
+ success_metrics: List[str]
57
+ approval_required: bool
58
+ quick_win: bool
59
+ strategic_value: str
60
+
61
+
62
+ @dataclass
63
+ class ManagerDashboardConfig:
64
+ """Configuration for manager dashboard behavior"""
65
+
66
+ safety_mode: bool = True
67
+ auto_export: bool = True
68
+ executive_summaries_only: bool = False
69
+ approval_threshold: float = 1000.0
70
+ target_savings_percentage: float = 30.0
71
+ max_implementation_weeks: int = 12
72
+ preferred_export_formats: List[str] = None
73
+
74
+ def __post_init__(self):
75
+ if self.preferred_export_formats is None:
76
+ self.preferred_export_formats = ["json", "csv", "excel"]
77
+
78
+
79
+ class VPCManagerInterface:
80
+ """
81
+ Manager-friendly interface for VPC cost optimization
82
+
83
+ This class provides high-level business methods that abstract away
84
+ technical complexity while providing comprehensive cost optimization
85
+ insights for executive decision making.
86
+ """
87
+
88
+ def __init__(self, console: Optional[Console] = None):
89
+ self.console = console or Console(force_jupyter=True, width=100)
90
+ self.config = ManagerDashboardConfig()
91
+ self.analysis_results = {}
92
+ self.business_recommendations = []
93
+ self.export_directory = Path("./exports/manager_dashboard")
94
+
95
+ def configure_for_business_user(
96
+ self, safety_mode: bool = True, target_savings: float = 30.0, approval_threshold: float = 1000.0
97
+ ) -> None:
98
+ """
99
+ Configure interface for business user preferences
100
+
101
+ Args:
102
+ safety_mode: Enable dry-run only mode for safety
103
+ target_savings: Target cost reduction percentage
104
+ approval_threshold: Dollar threshold requiring management approval
105
+ """
106
+ self.config.safety_mode = safety_mode
107
+ self.config.target_savings_percentage = target_savings
108
+ self.config.approval_threshold = approval_threshold
109
+
110
+ self.console.print(
111
+ Panel.fit(
112
+ f"[bold green]✅ Manager Interface Configured[/bold green]\n\n"
113
+ f"Safety Mode: {'[green]ON[/green]' if safety_mode else '[red]OFF[/red]'}\n"
114
+ f"Target Savings: [blue]{target_savings}%[/blue]\n"
115
+ f"Approval Threshold: [yellow]${approval_threshold:,.2f}[/yellow]",
116
+ title="Business Configuration",
117
+ )
118
+ )
119
+
120
+ def analyze_cost_optimization_opportunity(self, vpc_analysis_results: Dict[str, Any]) -> Dict[str, Any]:
121
+ """
122
+ Convert technical VPC analysis into business-focused insights
123
+
124
+ Args:
125
+ vpc_analysis_results: Raw technical analysis from VPC wrapper
126
+
127
+ Returns:
128
+ Dictionary with business-focused analysis results
129
+ """
130
+ self.console.print("[cyan]🔍 Converting technical analysis to business insights...[/cyan]")
131
+
132
+ # Extract business metrics
133
+ business_analysis = {
134
+ "executive_summary": self._create_executive_summary(vpc_analysis_results),
135
+ "financial_impact": self._calculate_financial_impact(vpc_analysis_results),
136
+ "risk_assessment": self._assess_business_risks(vpc_analysis_results),
137
+ "implementation_plan": self._create_implementation_plan(vpc_analysis_results),
138
+ "success_metrics": self._define_success_metrics(vpc_analysis_results),
139
+ "approval_requirements": self._determine_approval_requirements(vpc_analysis_results),
140
+ }
141
+
142
+ # Store for later export
143
+ self.analysis_results = business_analysis
144
+
145
+ # Generate business recommendations
146
+ self.business_recommendations = self._generate_business_recommendations(vpc_analysis_results, business_analysis)
147
+
148
+ return business_analysis
149
+
150
+ def _create_executive_summary(self, analysis: Dict[str, Any]) -> Dict[str, Any]:
151
+ """Create executive summary from technical analysis"""
152
+
153
+ # Extract key financial metrics
154
+ total_cost = 0
155
+ total_savings = 0
156
+
157
+ for component in ["nat_gateways", "vpc_endpoints", "transit_gateway"]:
158
+ if component in analysis:
159
+ comp_data = analysis[component]
160
+ total_cost += comp_data.get("total_cost", 0) or comp_data.get("total_monthly_cost", 0)
161
+ total_savings += comp_data.get("optimization_potential", 0) or comp_data.get("potential_savings", 0)
162
+
163
+ savings_percentage = (total_savings / total_cost * 100) if total_cost > 0 else 0
164
+ target_achieved = savings_percentage >= self.config.target_savings_percentage
165
+
166
+ return {
167
+ "current_monthly_cost": total_cost,
168
+ "potential_monthly_savings": total_savings,
169
+ "savings_percentage": savings_percentage,
170
+ "annual_savings_potential": total_savings * 12,
171
+ "target_achieved": target_achieved,
172
+ "payback_period_months": 1, # Most VPC optimizations have immediate payback
173
+ "confidence_level": "High",
174
+ "business_case_strength": "Excellent"
175
+ if savings_percentage >= 30
176
+ else "Good"
177
+ if savings_percentage >= 20
178
+ else "Moderate",
179
+ }
180
+
181
+ def _calculate_financial_impact(self, analysis: Dict[str, Any]) -> Dict[str, Any]:
182
+ """Calculate comprehensive financial impact"""
183
+
184
+ exec_summary = self._create_executive_summary(analysis)
185
+
186
+ return {
187
+ "immediate_savings": {
188
+ "monthly": exec_summary["potential_monthly_savings"],
189
+ "quarterly": exec_summary["potential_monthly_savings"] * 3,
190
+ "annual": exec_summary["annual_savings_potential"],
191
+ },
192
+ "cost_avoidance": {
193
+ "description": "Prevents future cost growth from inefficient resources",
194
+ "annual_value": exec_summary["annual_savings_potential"] * 0.1, # 10% growth avoidance
195
+ },
196
+ "implementation_cost": {
197
+ "personnel_time": "Existing team allocation",
198
+ "infrastructure_changes": "Minimal - configuration only",
199
+ "estimated_hours": 40, # Conservative estimate
200
+ "estimated_cost": 5000, # Based on average engineer cost
201
+ },
202
+ "roi_analysis": {
203
+ "investment": 5000,
204
+ "annual_return": exec_summary["annual_savings_potential"],
205
+ "roi_percentage": (exec_summary["annual_savings_potential"] / 5000 * 100)
206
+ if exec_summary["annual_savings_potential"] > 0
207
+ else 0,
208
+ "payback_months": max(1, 5000 / max(exec_summary["potential_monthly_savings"], 1)),
209
+ },
210
+ }
211
+
212
+ def _assess_business_risks(self, analysis: Dict[str, Any]) -> Dict[str, Any]:
213
+ """Assess business risks of optimization implementation"""
214
+
215
+ total_cost = sum(
216
+ [
217
+ analysis.get("nat_gateways", {}).get("total_cost", 0),
218
+ analysis.get("vpc_endpoints", {}).get("total_cost", 0),
219
+ analysis.get("transit_gateway", {}).get("total_monthly_cost", 0),
220
+ ]
221
+ )
222
+
223
+ # Risk assessment based on cost and complexity
224
+ risk_level = RiskLevel.LOW
225
+ if total_cost > 500:
226
+ risk_level = RiskLevel.MEDIUM
227
+ if total_cost > 1000:
228
+ risk_level = RiskLevel.HIGH
229
+
230
+ return {
231
+ "overall_risk": risk_level.value,
232
+ "risk_factors": [
233
+ {
234
+ "factor": "Service disruption during implementation",
235
+ "probability": "Low",
236
+ "impact": "Medium",
237
+ "mitigation": "Gradual rollout with testing",
238
+ },
239
+ {
240
+ "factor": "Configuration errors",
241
+ "probability": "Low",
242
+ "impact": "High",
243
+ "mitigation": "Dry-run validation and peer review",
244
+ },
245
+ {
246
+ "factor": "Cost increase if misconfigured",
247
+ "probability": "Very Low",
248
+ "impact": "Medium",
249
+ "mitigation": "Cost monitoring and automated alerts",
250
+ },
251
+ ],
252
+ "mitigation_strategies": [
253
+ "Implement changes in non-production first",
254
+ "Use Infrastructure as Code for consistency",
255
+ "Enable comprehensive monitoring and alerting",
256
+ "Maintain rollback procedures",
257
+ "Conduct thorough testing before production",
258
+ ],
259
+ "business_continuity": "No impact expected with proper implementation",
260
+ }
261
+
262
+ def _create_implementation_plan(self, analysis: Dict[str, Any]) -> Dict[str, Any]:
263
+ """Create business-focused implementation plan"""
264
+
265
+ exec_summary = self._create_executive_summary(analysis)
266
+
267
+ phases = [
268
+ {
269
+ "phase": 1,
270
+ "name": "Quick Wins & Foundation",
271
+ "duration": "2-4 weeks",
272
+ "savings": exec_summary["potential_monthly_savings"] * 0.4, # 40% of savings
273
+ "activities": [
274
+ "Deploy free Gateway VPC Endpoints",
275
+ "Implement cost monitoring",
276
+ "Analyze underutilized resources",
277
+ ],
278
+ "risk": "Low",
279
+ "approval_required": exec_summary["potential_monthly_savings"] * 12 > self.config.approval_threshold,
280
+ },
281
+ {
282
+ "phase": 2,
283
+ "name": "Strategic Optimization",
284
+ "duration": "4-8 weeks",
285
+ "savings": exec_summary["potential_monthly_savings"] * 0.6, # 60% of savings
286
+ "activities": [
287
+ "Optimize NAT Gateway usage",
288
+ "Deploy strategic Interface endpoints",
289
+ "Consolidate Transit Gateway attachments",
290
+ ],
291
+ "risk": "Medium",
292
+ "approval_required": True,
293
+ },
294
+ ]
295
+
296
+ return {
297
+ "total_timeline": "6-12 weeks",
298
+ "phases": phases,
299
+ "resource_requirements": {
300
+ "project_manager": "25% allocation for 3 months",
301
+ "cloud_engineer": "75% allocation for 6 weeks",
302
+ "solutions_architect": "50% allocation for 2 weeks",
303
+ "security_engineer": "25% allocation for 1 week",
304
+ },
305
+ "success_criteria": [
306
+ f"Achieve {self.config.target_savings_percentage}% cost reduction",
307
+ "No service disruptions during implementation",
308
+ "All changes validated in non-production first",
309
+ "Cost monitoring and alerting operational",
310
+ ],
311
+ }
312
+
313
+ def _define_success_metrics(self, analysis: Dict[str, Any]) -> List[Dict[str, Any]]:
314
+ """Define business success metrics"""
315
+
316
+ exec_summary = self._create_executive_summary(analysis)
317
+
318
+ return [
319
+ {
320
+ "metric": "Monthly Cost Reduction",
321
+ "target": f"${exec_summary['potential_monthly_savings']:.2f}",
322
+ "measurement": "AWS billing comparison",
323
+ "frequency": "Monthly",
324
+ },
325
+ {
326
+ "metric": "Savings Percentage",
327
+ "target": f"{self.config.target_savings_percentage}%+",
328
+ "measurement": "Automated cost analysis",
329
+ "frequency": "Weekly",
330
+ },
331
+ {
332
+ "metric": "Implementation Timeline",
333
+ "target": "< 12 weeks",
334
+ "measurement": "Project milestone tracking",
335
+ "frequency": "Weekly",
336
+ },
337
+ {
338
+ "metric": "Business Continuity",
339
+ "target": "Zero disruptions",
340
+ "measurement": "Incident tracking",
341
+ "frequency": "Continuous",
342
+ },
343
+ {
344
+ "metric": "ROI Achievement",
345
+ "target": f"> {((exec_summary['annual_savings_potential'] / 5000 * 100) if exec_summary['annual_savings_potential'] > 0 else 0):.0f}%",
346
+ "measurement": "Financial analysis",
347
+ "frequency": "Quarterly",
348
+ },
349
+ ]
350
+
351
+ def _determine_approval_requirements(self, analysis: Dict[str, Any]) -> Dict[str, Any]:
352
+ """Determine what approvals are needed"""
353
+
354
+ exec_summary = self._create_executive_summary(analysis)
355
+ annual_impact = exec_summary["annual_savings_potential"]
356
+
357
+ approvals_needed = []
358
+
359
+ if annual_impact > self.config.approval_threshold:
360
+ approvals_needed.append(
361
+ {
362
+ "type": "Financial Approval",
363
+ "reason": f"Annual impact ${annual_impact:,.2f} exceeds threshold",
364
+ "approver": "Finance/Management",
365
+ "timeline": "1-2 weeks",
366
+ }
367
+ )
368
+
369
+ if exec_summary["current_monthly_cost"] > 500:
370
+ approvals_needed.append(
371
+ {
372
+ "type": "Technical Approval",
373
+ "reason": "High-value infrastructure changes",
374
+ "approver": "Solutions Architecture",
375
+ "timeline": "1 week",
376
+ }
377
+ )
378
+
379
+ return {
380
+ "approvals_required": len(approvals_needed) > 0,
381
+ "approval_list": approvals_needed,
382
+ "estimated_approval_timeline": "2-3 weeks" if approvals_needed else "0 weeks",
383
+ "bypass_criteria": "Emergency cost optimization directive",
384
+ }
385
+
386
+ def _generate_business_recommendations(
387
+ self, analysis: Dict[str, Any], business_analysis: Dict[str, Any]
388
+ ) -> List[BusinessRecommendation]:
389
+ """Generate business-focused recommendations"""
390
+
391
+ recommendations = []
392
+ exec_summary = business_analysis["executive_summary"]
393
+
394
+ # Quick Win: Gateway VPC Endpoints
395
+ recommendations.append(
396
+ BusinessRecommendation(
397
+ title="Deploy Free Gateway VPC Endpoints",
398
+ executive_summary="Eliminate NAT Gateway charges for S3 and DynamoDB traffic with zero-cost solution",
399
+ monthly_savings=25.0,
400
+ annual_impact=300.0,
401
+ implementation_timeline="1-2 weeks",
402
+ business_priority=BusinessPriority.HIGH,
403
+ risk_level=RiskLevel.MINIMAL,
404
+ resource_requirements=["Cloud Engineer (1 week)"],
405
+ success_metrics=["NAT Gateway data transfer reduction", "Zero implementation cost"],
406
+ approval_required=False,
407
+ quick_win=True,
408
+ strategic_value="Foundation for advanced VPC optimization",
409
+ )
410
+ )
411
+
412
+ # Strategic: NAT Gateway Optimization
413
+ if analysis.get("nat_gateways", {}).get("optimization_potential", 0) > 20:
414
+ recommendations.append(
415
+ BusinessRecommendation(
416
+ title="Optimize Underutilized NAT Gateways",
417
+ executive_summary="Remove or consolidate NAT Gateways with low utilization to eliminate waste",
418
+ monthly_savings=analysis["nat_gateways"]["optimization_potential"],
419
+ annual_impact=analysis["nat_gateways"]["optimization_potential"] * 12,
420
+ implementation_timeline="3-4 weeks",
421
+ business_priority=BusinessPriority.HIGH,
422
+ risk_level=RiskLevel.MEDIUM,
423
+ resource_requirements=["Cloud Engineer (2 weeks)", "Security review"],
424
+ success_metrics=["Resource utilization improvement", "Cost per connection reduction"],
425
+ approval_required=analysis["nat_gateways"]["optimization_potential"] * 12
426
+ > self.config.approval_threshold,
427
+ quick_win=False,
428
+ strategic_value="Long-term infrastructure efficiency improvement",
429
+ )
430
+ )
431
+
432
+ # Advanced: Transit Gateway Optimization
433
+ tgw_savings = analysis.get("transit_gateway", {}).get("potential_savings", 0)
434
+ if tgw_savings > 30:
435
+ recommendations.append(
436
+ BusinessRecommendation(
437
+ title="Optimize Multi-Account Network Architecture",
438
+ executive_summary="Consolidate Transit Gateway attachments and implement centralized endpoints",
439
+ monthly_savings=tgw_savings,
440
+ annual_impact=tgw_savings * 12,
441
+ implementation_timeline="6-8 weeks",
442
+ business_priority=BusinessPriority.MEDIUM,
443
+ risk_level=RiskLevel.HIGH,
444
+ resource_requirements=["Solutions Architect (3 weeks)", "Network Engineer (2 weeks)"],
445
+ success_metrics=["Multi-account cost efficiency", "Network architecture optimization"],
446
+ approval_required=True,
447
+ quick_win=False,
448
+ strategic_value="Enterprise-scale network optimization and future-proofing",
449
+ )
450
+ )
451
+
452
+ return recommendations
453
+
454
+ def generate_executive_presentation(self) -> Dict[str, Any]:
455
+ """Generate executive presentation content"""
456
+
457
+ if not self.analysis_results:
458
+ raise ValueError("No analysis results available. Run cost analysis first.")
459
+
460
+ exec_summary = self.analysis_results["executive_summary"]
461
+ financial_impact = self.analysis_results["financial_impact"]
462
+
463
+ presentation = {
464
+ "slide_1": {
465
+ "title": "VPC Cost Optimization Opportunity",
466
+ "content": [
467
+ f"Current monthly cost: ${exec_summary['current_monthly_cost']:,.2f}",
468
+ f"Potential savings: ${exec_summary['potential_monthly_savings']:,.2f} ({exec_summary['savings_percentage']:.1f}%)",
469
+ f"Annual impact: ${exec_summary['annual_savings_potential']:,.2f}",
470
+ f"Business case: {exec_summary['business_case_strength']}",
471
+ ],
472
+ },
473
+ "slide_2": {
474
+ "title": "Financial Impact & ROI",
475
+ "content": [
476
+ f"ROI: {financial_impact['roi_analysis']['roi_percentage']:.0f}%",
477
+ f"Payback period: {financial_impact['roi_analysis']['payback_months']:.0f} months",
478
+ f"Implementation cost: ${financial_impact['implementation_cost']['estimated_cost']:,.2f}",
479
+ f"Net annual benefit: ${exec_summary['annual_savings_potential'] - financial_impact['implementation_cost']['estimated_cost']:,.2f}",
480
+ ],
481
+ },
482
+ "slide_3": {
483
+ "title": "Implementation Plan",
484
+ "content": [
485
+ "Phase 1: Quick wins (2-4 weeks)",
486
+ "Phase 2: Strategic optimization (4-8 weeks)",
487
+ f"Total timeline: {self.analysis_results['implementation_plan']['total_timeline']}",
488
+ f"Risk level: {self.analysis_results['risk_assessment']['overall_risk']}",
489
+ ],
490
+ },
491
+ "slide_4": {
492
+ "title": "Business Benefits",
493
+ "content": [
494
+ "Immediate cost reduction",
495
+ "Improved network security through VPC endpoints",
496
+ "Enhanced operational efficiency",
497
+ "Foundation for ongoing optimization",
498
+ ],
499
+ },
500
+ "slide_5": {
501
+ "title": "Next Steps",
502
+ "content": [
503
+ "Approve Phase 1 implementation",
504
+ "Assign technical resources",
505
+ "Schedule weekly progress reviews",
506
+ "Plan Phase 2 strategic optimization",
507
+ ],
508
+ },
509
+ }
510
+
511
+ return presentation
512
+
513
+ def export_manager_friendly_reports(self, timestamp: Optional[str] = None) -> Dict[str, str]:
514
+ """Export comprehensive manager-friendly reports"""
515
+
516
+ if not self.analysis_results:
517
+ raise ValueError("No analysis results to export")
518
+
519
+ timestamp = timestamp or datetime.now().strftime("%Y%m%d_%H%M%S")
520
+ self.export_directory.mkdir(parents=True, exist_ok=True)
521
+
522
+ exported_files = {}
523
+
524
+ # 1. Executive Summary (JSON)
525
+ executive_report = {
526
+ "metadata": {
527
+ "report_type": "vpc_cost_optimization_executive",
528
+ "generated_at": datetime.now().isoformat(),
529
+ "version": "2.0",
530
+ },
531
+ "analysis_results": self.analysis_results,
532
+ "business_recommendations": [asdict(rec) for rec in self.business_recommendations],
533
+ "executive_presentation": self.generate_executive_presentation(),
534
+ }
535
+
536
+ exec_file = self.export_directory / f"executive_report_{timestamp}.json"
537
+ with open(exec_file, "w") as f:
538
+ json.dump(executive_report, f, indent=2, default=str)
539
+ exported_files["executive_report"] = str(exec_file)
540
+
541
+ # 2. Business Recommendations CSV
542
+ if self.business_recommendations:
543
+ recommendations_data = []
544
+ for rec in self.business_recommendations:
545
+ recommendations_data.append(
546
+ {
547
+ "Title": rec.title,
548
+ "Monthly Savings": rec.monthly_savings,
549
+ "Annual Impact": rec.annual_impact,
550
+ "Priority": rec.business_priority.value,
551
+ "Risk Level": rec.risk_level.value,
552
+ "Timeline": rec.implementation_timeline,
553
+ "Quick Win": rec.quick_win,
554
+ "Approval Required": rec.approval_required,
555
+ "Strategic Value": rec.strategic_value,
556
+ }
557
+ )
558
+
559
+ rec_df = pd.DataFrame(recommendations_data)
560
+ rec_file = self.export_directory / f"business_recommendations_{timestamp}.csv"
561
+ rec_df.to_csv(rec_file, index=False)
562
+ exported_files["recommendations"] = str(rec_file)
563
+
564
+ # 3. Financial Analysis Spreadsheet
565
+ financial_data = {
566
+ "Metric": [
567
+ "Current Monthly Cost",
568
+ "Potential Monthly Savings",
569
+ "Annual Savings",
570
+ "Implementation Cost",
571
+ "Net Annual Benefit",
572
+ "ROI Percentage",
573
+ "Payback Period (Months)",
574
+ ],
575
+ "Value": [
576
+ self.analysis_results["executive_summary"]["current_monthly_cost"],
577
+ self.analysis_results["executive_summary"]["potential_monthly_savings"],
578
+ self.analysis_results["executive_summary"]["annual_savings_potential"],
579
+ self.analysis_results["financial_impact"]["implementation_cost"]["estimated_cost"],
580
+ self.analysis_results["executive_summary"]["annual_savings_potential"]
581
+ - self.analysis_results["financial_impact"]["implementation_cost"]["estimated_cost"],
582
+ self.analysis_results["financial_impact"]["roi_analysis"]["roi_percentage"],
583
+ self.analysis_results["financial_impact"]["roi_analysis"]["payback_months"],
584
+ ],
585
+ }
586
+
587
+ financial_df = pd.DataFrame(financial_data)
588
+ financial_file = self.export_directory / f"financial_analysis_{timestamp}.csv"
589
+ financial_df.to_csv(financial_file, index=False)
590
+ exported_files["financial_analysis"] = str(financial_file)
591
+
592
+ return exported_files
593
+
594
+ def display_business_dashboard(self) -> None:
595
+ """Display comprehensive business dashboard"""
596
+
597
+ if not self.analysis_results:
598
+ self.console.print("[red]❌ No analysis results available[/red]")
599
+ return
600
+
601
+ exec_summary = self.analysis_results["executive_summary"]
602
+ financial = self.analysis_results["financial_impact"]
603
+
604
+ # Main dashboard panel
605
+ dashboard_content = (
606
+ f"[bold blue]💰 FINANCIAL IMPACT[/bold blue]\n"
607
+ f"Monthly Cost: [red]${exec_summary['current_monthly_cost']:,.2f}[/red]\n"
608
+ f"Monthly Savings: [green]${exec_summary['potential_monthly_savings']:,.2f}[/green]\n"
609
+ f"Annual Impact: [bold green]${exec_summary['annual_savings_potential']:,.2f}[/bold green]\n"
610
+ f"Savings Target: {exec_summary['savings_percentage']:.1f}% "
611
+ f"({'[green]✅ ACHIEVED[/green]' if exec_summary['target_achieved'] else '[yellow]⚠️ PARTIAL[/yellow]'})\n\n"
612
+ f"[bold yellow]📊 BUSINESS CASE[/bold yellow]\n"
613
+ f"ROI: [green]{financial['roi_analysis']['roi_percentage']:.0f}%[/green]\n"
614
+ f"Payback: [blue]{financial['roi_analysis']['payback_months']:.0f} months[/blue]\n"
615
+ f"Business Strength: [cyan]{exec_summary['business_case_strength']}[/cyan]\n"
616
+ f"Risk Level: [magenta]{self.analysis_results['risk_assessment']['overall_risk']}[/magenta]\n\n"
617
+ f"[bold green]🎯 RECOMMENDATIONS[/bold green]\n"
618
+ f"Total Recommendations: [yellow]{len(self.business_recommendations)}[/yellow]\n"
619
+ f"Quick Wins: [green]{sum(1 for r in self.business_recommendations if r.quick_win)}[/green]\n"
620
+ f"Approval Required: [red]{sum(1 for r in self.business_recommendations if r.approval_required)}[/red]"
621
+ )
622
+
623
+ dashboard_panel = Panel(
624
+ dashboard_content, title="VPC Cost Optimization - Business Dashboard", style="white", width=80
625
+ )
626
+
627
+ self.console.print(dashboard_panel)
628
+
629
+ # Recommendations table
630
+ if self.business_recommendations:
631
+ rec_table = Table(title="Business Recommendations", show_header=True)
632
+ rec_table.add_column("Title", style="cyan")
633
+ rec_table.add_column("Monthly Savings", justify="right", style="green")
634
+ rec_table.add_column("Priority", style="yellow")
635
+ rec_table.add_column("Risk", style="red")
636
+ rec_table.add_column("Timeline", style="blue")
637
+ rec_table.add_column("Quick Win", style="magenta")
638
+
639
+ for rec in self.business_recommendations:
640
+ rec_table.add_row(
641
+ rec.title,
642
+ f"${rec.monthly_savings:.2f}",
643
+ rec.business_priority.value,
644
+ rec.risk_level.value,
645
+ rec.implementation_timeline,
646
+ "✅" if rec.quick_win else "⏳",
647
+ )
648
+
649
+ self.console.print(rec_table)