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