runbooks 0.7.9__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 (95) hide show
  1. runbooks/__init__.py +1 -1
  2. runbooks/cfat/README.md +12 -1
  3. runbooks/cfat/__init__.py +1 -1
  4. runbooks/cfat/assessment/runner.py +42 -34
  5. runbooks/cfat/models.py +1 -1
  6. runbooks/common/__init__.py +152 -0
  7. runbooks/common/accuracy_validator.py +1039 -0
  8. runbooks/common/context_logger.py +440 -0
  9. runbooks/common/cross_module_integration.py +594 -0
  10. runbooks/common/enhanced_exception_handler.py +1108 -0
  11. runbooks/common/enterprise_audit_integration.py +634 -0
  12. runbooks/common/mcp_integration.py +539 -0
  13. runbooks/common/performance_monitor.py +387 -0
  14. runbooks/common/profile_utils.py +216 -0
  15. runbooks/common/rich_utils.py +171 -0
  16. runbooks/feedback/user_feedback_collector.py +440 -0
  17. runbooks/finops/README.md +339 -451
  18. runbooks/finops/__init__.py +4 -21
  19. runbooks/finops/account_resolver.py +279 -0
  20. runbooks/finops/accuracy_cross_validator.py +638 -0
  21. runbooks/finops/aws_client.py +721 -36
  22. runbooks/finops/budget_integration.py +313 -0
  23. runbooks/finops/cli.py +59 -5
  24. runbooks/finops/cost_processor.py +211 -37
  25. runbooks/finops/dashboard_router.py +900 -0
  26. runbooks/finops/dashboard_runner.py +990 -232
  27. runbooks/finops/embedded_mcp_validator.py +288 -0
  28. runbooks/finops/enhanced_dashboard_runner.py +8 -7
  29. runbooks/finops/enhanced_progress.py +327 -0
  30. runbooks/finops/enhanced_trend_visualization.py +423 -0
  31. runbooks/finops/finops_dashboard.py +29 -1880
  32. runbooks/finops/helpers.py +509 -196
  33. runbooks/finops/iam_guidance.py +400 -0
  34. runbooks/finops/markdown_exporter.py +466 -0
  35. runbooks/finops/multi_dashboard.py +1502 -0
  36. runbooks/finops/optimizer.py +15 -15
  37. runbooks/finops/profile_processor.py +2 -2
  38. runbooks/finops/runbooks.inventory.organizations_discovery.log +0 -0
  39. runbooks/finops/runbooks.security.report_generator.log +0 -0
  40. runbooks/finops/runbooks.security.run_script.log +0 -0
  41. runbooks/finops/runbooks.security.security_export.log +0 -0
  42. runbooks/finops/service_mapping.py +195 -0
  43. runbooks/finops/single_dashboard.py +710 -0
  44. runbooks/finops/tests/test_reference_images_validation.py +1 -1
  45. runbooks/inventory/README.md +12 -1
  46. runbooks/inventory/core/collector.py +157 -29
  47. runbooks/inventory/list_ec2_instances.py +9 -6
  48. runbooks/inventory/list_ssm_parameters.py +10 -10
  49. runbooks/inventory/organizations_discovery.py +210 -164
  50. runbooks/inventory/rich_inventory_display.py +74 -107
  51. runbooks/inventory/run_on_multi_accounts.py +13 -13
  52. runbooks/main.py +740 -134
  53. runbooks/metrics/dora_metrics_engine.py +711 -17
  54. runbooks/monitoring/performance_monitor.py +433 -0
  55. runbooks/operate/README.md +394 -0
  56. runbooks/operate/base.py +215 -47
  57. runbooks/operate/ec2_operations.py +7 -5
  58. runbooks/operate/privatelink_operations.py +1 -1
  59. runbooks/operate/vpc_endpoints.py +1 -1
  60. runbooks/remediation/README.md +489 -13
  61. runbooks/remediation/commons.py +8 -4
  62. runbooks/security/ENTERPRISE_SECURITY_FRAMEWORK.md +506 -0
  63. runbooks/security/README.md +12 -1
  64. runbooks/security/__init__.py +164 -33
  65. runbooks/security/compliance_automation.py +12 -10
  66. runbooks/security/compliance_automation_engine.py +1021 -0
  67. runbooks/security/enterprise_security_framework.py +931 -0
  68. runbooks/security/enterprise_security_policies.json +293 -0
  69. runbooks/security/integration_test_enterprise_security.py +879 -0
  70. runbooks/security/module_security_integrator.py +641 -0
  71. runbooks/security/report_generator.py +1 -1
  72. runbooks/security/run_script.py +4 -8
  73. runbooks/security/security_baseline_tester.py +36 -49
  74. runbooks/security/security_export.py +99 -120
  75. runbooks/sre/README.md +472 -0
  76. runbooks/sre/__init__.py +33 -0
  77. runbooks/sre/mcp_reliability_engine.py +1049 -0
  78. runbooks/sre/performance_optimization_engine.py +1032 -0
  79. runbooks/sre/reliability_monitoring_framework.py +1011 -0
  80. runbooks/validation/__init__.py +2 -2
  81. runbooks/validation/benchmark.py +154 -149
  82. runbooks/validation/cli.py +159 -147
  83. runbooks/validation/mcp_validator.py +265 -236
  84. runbooks/vpc/README.md +478 -0
  85. runbooks/vpc/__init__.py +2 -2
  86. runbooks/vpc/manager_interface.py +366 -351
  87. runbooks/vpc/networking_wrapper.py +62 -33
  88. runbooks/vpc/rich_formatters.py +22 -8
  89. {runbooks-0.7.9.dist-info → runbooks-0.9.0.dist-info}/METADATA +136 -54
  90. {runbooks-0.7.9.dist-info → runbooks-0.9.0.dist-info}/RECORD +94 -55
  91. {runbooks-0.7.9.dist-info → runbooks-0.9.0.dist-info}/entry_points.txt +1 -1
  92. runbooks/finops/cross_validation.py +0 -375
  93. {runbooks-0.7.9.dist-info → runbooks-0.9.0.dist-info}/WHEEL +0 -0
  94. {runbooks-0.7.9.dist-info → runbooks-0.9.0.dist-info}/licenses/LICENSE +0 -0
  95. {runbooks-0.7.9.dist-info → runbooks-0.9.0.dist-info}/top_level.txt +0 -0
@@ -303,9 +303,9 @@ class CostOptimizer:
303
303
  total_monthly_savings = sum(op.potential_savings for op in self.opportunities)
304
304
  total_annual_savings = total_monthly_savings * 12
305
305
 
306
- # Estimate current spend (this would come from Cost Explorer in production)
307
- estimated_current_monthly_spend = 292000 # $3.5M annual / 12 months
308
- savings_percentage = (total_monthly_savings / estimated_current_monthly_spend) * 100
306
+ # Note: Current spend estimation requires real Cost Explorer API data
307
+ # Hardcoded values removed per compliance requirements
308
+ savings_percentage = 0.0 # Cannot calculate without real baseline cost data
309
309
 
310
310
  return {
311
311
  "monthly": total_monthly_savings,
@@ -464,18 +464,18 @@ class CostOptimizer:
464
464
 
465
465
  # Helper methods
466
466
  def _get_all_accounts(self) -> List[str]:
467
- """Get all AWS accounts from Organizations (enhanced for multi-account org)."""
468
- # Enhanced mock for multi-account organization
469
- base_accounts = ["123456789012", "234567890123", "345678901234"]
470
-
471
- # Generate additional accounts to simulate large organization
472
- additional_accounts = []
473
- for i in range(4, self.max_accounts + 1):
474
- # Generate realistic account IDs
475
- account_id = str(100000000000 + i * 11111)
476
- additional_accounts.append(account_id)
477
-
478
- all_accounts = base_accounts + additional_accounts
467
+ """Get all AWS accounts from Organizations (requires real Organizations API access)."""
468
+ # Note: Account discovery requires real AWS Organizations API
469
+ # Mock account generation removed per compliance requirements
470
+ try:
471
+ # This should use real AWS Organizations API calls
472
+ # Placeholder for real implementation
473
+ all_accounts = [] # Replace with real Organizations.list_accounts() call
474
+ if not all_accounts:
475
+ console.print("[yellow]No accounts discovered. Requires AWS Organizations API access.[/]")
476
+ except Exception as e:
477
+ console.print(f"[yellow]Organizations API error: {e}[/]")
478
+ all_accounts = []
479
479
  print(f"📊 Discovered {len(all_accounts)} accounts in organization")
480
480
  return all_accounts
481
481
 
@@ -33,7 +33,7 @@ def process_single_profile(
33
33
  """Process a single AWS profile and return its data."""
34
34
  try:
35
35
  session = boto3.Session(profile_name=profile)
36
- cost_data = get_cost_data(session, time_range, tag)
36
+ cost_data = get_cost_data(session, time_range, tag, profile_name=profile)
37
37
 
38
38
  if user_regions:
39
39
  profile_regions = user_regions
@@ -113,7 +113,7 @@ def process_combined_profiles(
113
113
 
114
114
  try:
115
115
  # Attempt to overwrite with actual data from Cost Explorer
116
- account_cost_data = get_cost_data(primary_session, time_range, tag)
116
+ account_cost_data = get_cost_data(primary_session, time_range, tag, profile_name=primary_profile)
117
117
  except Exception as e:
118
118
  console.log(f"[bold red]Error getting cost data for account {account_id}: {str(e)}[/]")
119
119
  # account_cost_data retains its default values if an error occurs
File without changes
File without changes
File without changes
@@ -0,0 +1,195 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ AWS Service Name Mapping and Standardization
4
+ Provides comprehensive mapping of AWS service names to standardized abbreviations
5
+ for space-efficient display in FinOps dashboards and reports.
6
+ """
7
+
8
+ from typing import Dict
9
+
10
+ # Comprehensive AWS Service Name Mapping Dictionary
11
+ # Maps full AWS service names to standardized short names for display
12
+ AWS_SERVICE_MAPPING: Dict[str, str] = {
13
+ # Compute Services
14
+ "Amazon Elastic Compute Cloud - Compute": "EC2",
15
+ "EC2 - Other": "EC2-Other",
16
+ "AWS Lambda": "Lambda",
17
+ "Amazon Elastic Container Service": "ECS",
18
+ "Amazon Elastic Kubernetes Service": "EKS",
19
+ "AWS Batch": "Batch",
20
+ "AWS Fargate": "Fargate",
21
+ # Storage Services
22
+ "Amazon Simple Storage Service": "S3",
23
+ "Amazon Elastic Block Store": "EBS",
24
+ "Amazon Elastic File System": "EFS",
25
+ "AWS Storage Gateway": "Storage-GW",
26
+ "Amazon FSx": "FSx",
27
+ # Database Services
28
+ "Amazon Relational Database Service": "RDS",
29
+ "Amazon DynamoDB": "DynamoDB",
30
+ "Amazon Redshift": "Redshift",
31
+ "Amazon ElastiCache": "ElastiCache",
32
+ "Amazon DocumentDB": "DocumentDB",
33
+ "Amazon Neptune": "Neptune",
34
+ "Amazon Timestream": "Timestream",
35
+ # Networking Services
36
+ "Amazon Virtual Private Cloud": "VPC",
37
+ "Amazon CloudFront": "CloudFront",
38
+ "Amazon Route 53": "Route53",
39
+ "AWS Direct Connect": "DirectConnect",
40
+ "Elastic Load Balancing": "ELB",
41
+ "Amazon API Gateway": "API-Gateway",
42
+ "AWS Transit Gateway": "Transit-GW",
43
+ # Monitoring & Management
44
+ "AmazonCloudWatch": "CloudWatch",
45
+ "AWS CloudTrail": "CloudTrail",
46
+ "AWS Config": "Config",
47
+ "AWS Systems Manager": "SSM",
48
+ "AWS X-Ray": "X-Ray",
49
+ "Amazon Inspector": "Inspector",
50
+ # Security Services
51
+ "AWS Identity and Access Management": "IAM",
52
+ "AWS Certificate Manager": "ACM",
53
+ "AWS Key Management Service": "KMS",
54
+ "AWS Secrets Manager": "Secrets-Mgr",
55
+ "Amazon Cognito": "Cognito",
56
+ "AWS Security Hub": "Security-Hub",
57
+ "Amazon GuardDuty": "GuardDuty",
58
+ # Analytics Services
59
+ "AWS Glue": "Glue",
60
+ "Amazon Kinesis": "Kinesis",
61
+ "Amazon EMR": "EMR",
62
+ "Amazon Athena": "Athena",
63
+ "Amazon QuickSight": "QuickSight",
64
+ "AWS Data Pipeline": "Data-Pipeline",
65
+ # Application Integration
66
+ "Amazon Simple Queue Service": "SQS",
67
+ "Amazon Simple Notification Service": "SNS",
68
+ "Amazon EventBridge": "EventBridge",
69
+ "AWS Step Functions": "Step-Functions",
70
+ "Amazon MQ": "MQ",
71
+ # Developer Tools
72
+ "AWS CodeCommit": "CodeCommit",
73
+ "AWS CodeBuild": "CodeBuild",
74
+ "AWS CodeDeploy": "CodeDeploy",
75
+ "AWS CodePipeline": "CodePipeline",
76
+ "AWS CodeStar": "CodeStar",
77
+ # Business Applications
78
+ "Amazon WorkSpaces": "WorkSpaces",
79
+ "Amazon AppStream 2.0": "AppStream",
80
+ "Amazon Connect": "Connect",
81
+ "Amazon Chime": "Chime",
82
+ # Cost Management
83
+ "AWS Cost Explorer": "Cost-Explorer",
84
+ "AWS Budgets": "Budgets",
85
+ "Savings Plans for AWS Compute usage": "Savings-Plans",
86
+ # Support & Billing
87
+ "AWS Support (Business)": "Support",
88
+ "AWS Support (Enterprise)": "Support-Ent",
89
+ "AWS Payment Cryptography": "Payment-Crypto",
90
+ # Special Cases and Variations
91
+ "Simple Storage Service": "S3",
92
+ "Virtual Private Cloud": "VPC",
93
+ "Elastic Compute Cloud": "EC2",
94
+ "Simple Queue Service": "SQS",
95
+ "Simple Notification Service": "SNS",
96
+ "Key Management Service": "KMS",
97
+ "Identity and Access Management": "IAM",
98
+ # Directory Services
99
+ "AWS Directory Service": "Directory",
100
+ "AWS Managed Microsoft AD": "Managed-AD",
101
+ # Machine Learning
102
+ "Amazon SageMaker": "SageMaker",
103
+ "Amazon Rekognition": "Rekognition",
104
+ "Amazon Comprehend": "Comprehend",
105
+ "Amazon Translate": "Translate",
106
+ # IoT Services
107
+ "AWS IoT Core": "IoT-Core",
108
+ "AWS IoT Device Management": "IoT-Device",
109
+ "AWS IoT Analytics": "IoT-Analytics",
110
+ # Transfer Services
111
+ "AWS Transfer Family": "Transfer",
112
+ "AWS DataSync": "DataSync",
113
+ "AWS Snow Family": "Snow",
114
+ # Contact Center
115
+ "Contact Center Telecommunications": "Contact-Center",
116
+ "Contact Lens for Amazon Connect": "Contact-Lens",
117
+ # WAF & Shield
118
+ "AWS WAF": "WAF",
119
+ "AWS Shield": "Shield",
120
+ # Email
121
+ "Amazon Simple Email Service": "SES",
122
+ # Tax
123
+ "Tax": "Tax", # Usually filtered out, but included for completeness
124
+ }
125
+
126
+
127
+ def get_service_display_name(service_name: str) -> str:
128
+ """
129
+ Get standardized display name for AWS service.
130
+
131
+ Args:
132
+ service_name: Full AWS service name
133
+
134
+ Returns:
135
+ Standardized short name for display
136
+ """
137
+ # Direct mapping lookup
138
+ if service_name in AWS_SERVICE_MAPPING:
139
+ return AWS_SERVICE_MAPPING[service_name]
140
+
141
+ # Fallback: Clean up common patterns
142
+ cleaned = service_name
143
+
144
+ # Remove common AWS prefixes
145
+ cleaned = cleaned.replace("Amazon ", "").replace("AWS ", "")
146
+
147
+ # Remove common suffixes
148
+ cleaned = cleaned.replace(" Service", "").replace(" (Business)", "")
149
+
150
+ # Handle long names by truncating intelligently
151
+ if len(cleaned) > 15:
152
+ # Try to get meaningful abbreviation
153
+ words = cleaned.split()
154
+ if len(words) > 1:
155
+ # Take first letter of each word for abbreviation
156
+ cleaned = "".join(word[0].upper() for word in words if word)
157
+ # If still too long, take first 12 characters
158
+ if len(cleaned) > 12:
159
+ cleaned = cleaned[:12]
160
+ else:
161
+ # Single long word, truncate with ellipsis
162
+ cleaned = cleaned[:12] + ("..." if len(cleaned) > 12 else "")
163
+
164
+ return cleaned
165
+
166
+
167
+ def get_top_services_display(services_dict: Dict[str, float], limit: int = 3) -> str:
168
+ """
169
+ Format top services for display with standardized names.
170
+
171
+ Args:
172
+ services_dict: Dictionary of service names to costs
173
+ limit: Number of top services to display
174
+
175
+ Returns:
176
+ Formatted string for display
177
+ """
178
+ if not services_dict:
179
+ return "[dim]None[/]"
180
+
181
+ # Sort by cost and take top services
182
+ sorted_services = sorted(services_dict.items(), key=lambda x: x[1], reverse=True)
183
+ top_services = sorted_services[:limit]
184
+
185
+ # Format for display
186
+ services_text = []
187
+ for service, cost in top_services:
188
+ display_name = get_service_display_name(service)
189
+ services_text.append(f"{display_name}: ${cost:.0f}")
190
+
191
+ return "\n".join(services_text)
192
+
193
+
194
+ # Export for other modules
195
+ __all__ = ["AWS_SERVICE_MAPPING", "get_service_display_name", "get_top_services_display"]