runbooks 1.1.9__py3-none-any.whl → 1.1.10__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/__init___optimized.py +2 -1
- runbooks/_platform/__init__.py +1 -1
- runbooks/cfat/cli.py +4 -3
- runbooks/cfat/cloud_foundations_assessment.py +1 -2
- runbooks/cfat/tests/test_cli.py +4 -1
- runbooks/cli/commands/finops.py +68 -19
- runbooks/cli/commands/inventory.py +796 -7
- runbooks/cli/commands/operate.py +65 -4
- runbooks/cloudops/cost_optimizer.py +1 -3
- runbooks/common/cli_decorators.py +6 -4
- runbooks/common/config_loader.py +787 -0
- runbooks/common/config_schema.py +280 -0
- runbooks/common/dry_run_framework.py +14 -2
- runbooks/common/mcp_integration.py +238 -0
- runbooks/finops/ebs_cost_optimizer.py +7 -4
- runbooks/finops/elastic_ip_optimizer.py +7 -4
- runbooks/finops/infrastructure/__init__.py +3 -2
- runbooks/finops/infrastructure/commands.py +7 -4
- runbooks/finops/infrastructure/load_balancer_optimizer.py +7 -4
- runbooks/finops/infrastructure/vpc_endpoint_optimizer.py +7 -4
- runbooks/finops/nat_gateway_optimizer.py +7 -4
- runbooks/finops/tests/run_tests.py +1 -1
- runbooks/inventory/ArgumentsClass.py +2 -1
- runbooks/inventory/README.md +111 -12
- runbooks/inventory/Tests/test_Inventory_Modules.py +27 -10
- runbooks/inventory/Tests/test_cfn_describe_stacks.py +18 -7
- runbooks/inventory/Tests/test_ec2_describe_instances.py +30 -15
- runbooks/inventory/Tests/test_lambda_list_functions.py +17 -3
- runbooks/inventory/Tests/test_org_list_accounts.py +17 -4
- runbooks/inventory/account_class.py +0 -1
- runbooks/inventory/all_my_instances_wrapper.py +4 -8
- runbooks/inventory/aws_organization.png +0 -0
- runbooks/inventory/check_cloudtrail_compliance.py +4 -4
- runbooks/inventory/check_controltower_readiness.py +50 -47
- runbooks/inventory/check_landingzone_readiness.py +35 -31
- runbooks/inventory/cloud_foundations_integration.py +8 -3
- runbooks/inventory/core/collector.py +201 -1
- runbooks/inventory/discovery.md +2 -1
- runbooks/inventory/{draw_org_structure.py → draw_org.py} +55 -9
- runbooks/inventory/drift_detection_cli.py +8 -68
- runbooks/inventory/find_cfn_drift_detection.py +14 -4
- runbooks/inventory/find_cfn_orphaned_stacks.py +7 -5
- runbooks/inventory/find_cfn_stackset_drift.py +5 -5
- runbooks/inventory/find_ec2_security_groups.py +6 -3
- runbooks/inventory/find_landingzone_versions.py +5 -5
- runbooks/inventory/find_vpc_flow_logs.py +5 -5
- runbooks/inventory/inventory.sh +20 -7
- runbooks/inventory/inventory_mcp_cli.py +4 -0
- runbooks/inventory/inventory_modules.py +9 -7
- runbooks/inventory/list_cfn_stacks.py +18 -8
- runbooks/inventory/list_cfn_stackset_operation_results.py +2 -2
- runbooks/inventory/list_cfn_stackset_operations.py +32 -20
- runbooks/inventory/list_cfn_stacksets.py +7 -4
- runbooks/inventory/list_config_recorders_delivery_channels.py +4 -4
- runbooks/inventory/list_ds_directories.py +3 -3
- runbooks/inventory/list_ec2_availability_zones.py +7 -3
- runbooks/inventory/list_ec2_ebs_volumes.py +3 -3
- runbooks/inventory/list_ec2_instances.py +1 -1
- runbooks/inventory/list_ecs_clusters_and_tasks.py +8 -4
- runbooks/inventory/list_elbs_load_balancers.py +7 -3
- runbooks/inventory/list_enis_network_interfaces.py +3 -3
- runbooks/inventory/list_guardduty_detectors.py +9 -5
- runbooks/inventory/list_iam_policies.py +7 -3
- runbooks/inventory/list_iam_roles.py +3 -3
- runbooks/inventory/list_iam_saml_providers.py +8 -4
- runbooks/inventory/list_lambda_functions.py +8 -4
- runbooks/inventory/list_org_accounts.py +306 -276
- runbooks/inventory/list_org_accounts_users.py +45 -9
- runbooks/inventory/list_rds_db_instances.py +4 -4
- runbooks/inventory/list_route53_hosted_zones.py +3 -3
- runbooks/inventory/list_servicecatalog_provisioned_products.py +5 -5
- runbooks/inventory/list_sns_topics.py +4 -4
- runbooks/inventory/list_ssm_parameters.py +6 -3
- runbooks/inventory/list_vpc_subnets.py +8 -4
- runbooks/inventory/list_vpcs.py +15 -4
- runbooks/inventory/mcp_vpc_validator.py +6 -0
- runbooks/inventory/organizations_discovery.py +17 -3
- runbooks/inventory/organizations_utils.py +553 -0
- runbooks/inventory/output_formatters.py +422 -0
- runbooks/inventory/recover_cfn_stack_ids.py +5 -5
- runbooks/inventory/run_on_multi_accounts.py +3 -3
- runbooks/inventory/tag_coverage.py +481 -0
- runbooks/inventory/validation_utils.py +358 -0
- runbooks/inventory/verify_ec2_security_groups.py +18 -5
- runbooks/inventory/vpc_architecture_validator.py +7 -1
- runbooks/inventory/vpc_dependency_analyzer.py +6 -0
- runbooks/main_final.py +2 -2
- runbooks/main_ultra_minimal.py +2 -2
- runbooks/mcp/integration.py +6 -4
- runbooks/remediation/acm_remediation.py +2 -2
- runbooks/remediation/cloudtrail_remediation.py +2 -2
- runbooks/remediation/cognito_remediation.py +2 -2
- runbooks/remediation/dynamodb_remediation.py +2 -2
- runbooks/remediation/ec2_remediation.py +2 -2
- runbooks/remediation/kms_remediation.py +2 -2
- runbooks/remediation/lambda_remediation.py +2 -2
- runbooks/remediation/rds_remediation.py +2 -2
- runbooks/remediation/s3_remediation.py +1 -1
- runbooks/vpc/cloudtrail_audit_integration.py +1 -1
- {runbooks-1.1.9.dist-info → runbooks-1.1.10.dist-info}/METADATA +74 -4
- {runbooks-1.1.9.dist-info → runbooks-1.1.10.dist-info}/RECORD +106 -100
- runbooks/__init__.py.backup +0 -134
- {runbooks-1.1.9.dist-info → runbooks-1.1.10.dist-info}/WHEEL +0 -0
- {runbooks-1.1.9.dist-info → runbooks-1.1.10.dist-info}/entry_points.txt +0 -0
- {runbooks-1.1.9.dist-info → runbooks-1.1.10.dist-info}/licenses/LICENSE +0 -0
- {runbooks-1.1.9.dist-info → runbooks-1.1.10.dist-info}/top_level.txt +0 -0
runbooks/cli/commands/operate.py
CHANGED
@@ -78,15 +78,27 @@ def create_operate_group():
|
|
78
78
|
"""Start EC2 instances with universal profile support."""
|
79
79
|
try:
|
80
80
|
from runbooks.operate import EC2Operations
|
81
|
+
from runbooks.operate.base import OperationContext
|
82
|
+
from runbooks.inventory.models.account import AWSAccount
|
81
83
|
from runbooks.common.profile_utils import get_profile_for_operation
|
82
84
|
|
83
85
|
# Use ProfileManager for dynamic profile resolution
|
84
86
|
resolved_profile = get_profile_for_operation("operational", profile)
|
85
87
|
|
88
|
+
# Create operation context
|
89
|
+
account = AWSAccount(account_id="current", account_name="cli-execution")
|
90
|
+
operation_context = OperationContext(
|
91
|
+
account=account,
|
92
|
+
region=region,
|
93
|
+
operation_type="start_instances",
|
94
|
+
resource_types=["ec2:instance"],
|
95
|
+
dry_run=dry_run
|
96
|
+
)
|
97
|
+
|
86
98
|
# Delegate to operate module with resolved profile
|
87
99
|
ec2_ops = EC2Operations(profile=resolved_profile, region=region, dry_run=dry_run)
|
88
100
|
|
89
|
-
return ec2_ops.start_instances(list(instance_ids))
|
101
|
+
return ec2_ops.start_instances(operation_context, list(instance_ids))
|
90
102
|
|
91
103
|
except ImportError as e:
|
92
104
|
console.print(f"[red]❌ EC2 operations module not available: {e}[/red]")
|
@@ -109,14 +121,26 @@ def create_operate_group():
|
|
109
121
|
"""Stop EC2 instances with universal profile support."""
|
110
122
|
try:
|
111
123
|
from runbooks.operate import EC2Operations
|
124
|
+
from runbooks.operate.base import OperationContext
|
125
|
+
from runbooks.inventory.models.account import AWSAccount
|
112
126
|
from runbooks.common.profile_utils import get_profile_for_operation
|
113
127
|
|
114
128
|
# Use ProfileManager for dynamic profile resolution
|
115
129
|
resolved_profile = get_profile_for_operation("operational", profile)
|
116
130
|
|
131
|
+
# Create operation context
|
132
|
+
account = AWSAccount(account_id="current", account_name="cli-execution")
|
133
|
+
operation_context = OperationContext(
|
134
|
+
account=account,
|
135
|
+
region=region,
|
136
|
+
operation_type="stop_instances",
|
137
|
+
resource_types=["ec2:instance"],
|
138
|
+
dry_run=dry_run
|
139
|
+
)
|
140
|
+
|
117
141
|
ec2_ops = EC2Operations(profile=resolved_profile, region=region, dry_run=dry_run)
|
118
142
|
|
119
|
-
return ec2_ops.stop_instances(list(instance_ids))
|
143
|
+
return ec2_ops.stop_instances(operation_context, list(instance_ids))
|
120
144
|
|
121
145
|
except ImportError as e:
|
122
146
|
console.print(f"[red]❌ EC2 operations module not available: {e}[/red]")
|
@@ -144,14 +168,27 @@ def create_operate_group():
|
|
144
168
|
"""Create S3 bucket with enterprise configurations and universal profile support."""
|
145
169
|
try:
|
146
170
|
from runbooks.operate import S3Operations
|
171
|
+
from runbooks.operate.base import OperationContext
|
172
|
+
from runbooks.inventory.models.account import AWSAccount
|
147
173
|
from runbooks.common.profile_utils import get_profile_for_operation
|
148
174
|
|
149
175
|
# Use ProfileManager for dynamic profile resolution
|
150
176
|
resolved_profile = get_profile_for_operation("operational", profile)
|
151
177
|
|
178
|
+
# Create operation context
|
179
|
+
account = AWSAccount(account_id="current", account_name="cli-execution")
|
180
|
+
operation_context = OperationContext(
|
181
|
+
account=account,
|
182
|
+
region=region,
|
183
|
+
operation_type="create_bucket",
|
184
|
+
resource_types=["s3:bucket"],
|
185
|
+
dry_run=dry_run
|
186
|
+
)
|
187
|
+
|
152
188
|
s3_ops = S3Operations(profile=resolved_profile, region=region, dry_run=dry_run)
|
153
189
|
|
154
190
|
return s3_ops.create_bucket(
|
191
|
+
operation_context,
|
155
192
|
bucket_name=bucket_name,
|
156
193
|
encryption=encryption,
|
157
194
|
versioning=versioning,
|
@@ -182,14 +219,26 @@ def create_operate_group():
|
|
182
219
|
"""Create VPC with enterprise configurations and universal profile support."""
|
183
220
|
try:
|
184
221
|
from runbooks.operate import VPCOperations
|
222
|
+
from runbooks.operate.base import OperationContext
|
223
|
+
from runbooks.inventory.models.account import AWSAccount
|
185
224
|
from runbooks.common.profile_utils import get_profile_for_operation
|
186
225
|
|
187
226
|
# Use ProfileManager for dynamic profile resolution
|
188
227
|
resolved_profile = get_profile_for_operation("operational", profile)
|
189
228
|
|
229
|
+
# Create operation context
|
230
|
+
account = AWSAccount(account_id="current", account_name="cli-execution")
|
231
|
+
operation_context = OperationContext(
|
232
|
+
account=account,
|
233
|
+
region=region,
|
234
|
+
operation_type="create_vpc",
|
235
|
+
resource_types=["vpc"],
|
236
|
+
dry_run=dry_run
|
237
|
+
)
|
238
|
+
|
190
239
|
vpc_ops = VPCOperations(profile=resolved_profile, region=region, dry_run=dry_run)
|
191
240
|
|
192
|
-
return vpc_ops.create_vpc(cidr_block=cidr_block, vpc_name=vpc_name)
|
241
|
+
return vpc_ops.create_vpc(operation_context, cidr_block=cidr_block, vpc_name=vpc_name)
|
193
242
|
|
194
243
|
except ImportError as e:
|
195
244
|
console.print(f"[red]❌ VPC operations module not available: {e}[/red]")
|
@@ -216,14 +265,26 @@ def create_operate_group():
|
|
216
265
|
"""Deploy CloudFormation stack with universal profile support."""
|
217
266
|
try:
|
218
267
|
from runbooks.operate import CloudFormationOperations
|
268
|
+
from runbooks.operate.base import OperationContext
|
269
|
+
from runbooks.inventory.models.account import AWSAccount
|
219
270
|
from runbooks.common.profile_utils import get_profile_for_operation
|
220
271
|
|
221
272
|
# Use ProfileManager for dynamic profile resolution
|
222
273
|
resolved_profile = get_profile_for_operation("operational", profile)
|
223
274
|
|
275
|
+
# Create operation context
|
276
|
+
account = AWSAccount(account_id="current", account_name="cli-execution")
|
277
|
+
operation_context = OperationContext(
|
278
|
+
account=account,
|
279
|
+
region=region,
|
280
|
+
operation_type="deploy_stack",
|
281
|
+
resource_types=["cloudformation:stack"],
|
282
|
+
dry_run=dry_run
|
283
|
+
)
|
284
|
+
|
224
285
|
cf_ops = CloudFormationOperations(profile=resolved_profile, region=region, dry_run=dry_run)
|
225
286
|
|
226
|
-
return cf_ops.deploy_stack(template_file=template_file, stack_name=stack_name, parameters=parameters)
|
287
|
+
return cf_ops.deploy_stack(operation_context, template_file=template_file, stack_name=stack_name, parameters=parameters)
|
227
288
|
|
228
289
|
except ImportError as e:
|
229
290
|
console.print(f"[red]❌ CloudFormation operations module not available: {e}[/red]")
|
@@ -124,9 +124,7 @@ class CostOptimizer(CloudOpsBase):
|
|
124
124
|
return time.time() - self.operation_start_time
|
125
125
|
else:
|
126
126
|
# Fallback if start time not tracked
|
127
|
-
|
128
|
-
|
129
|
-
return time.time() - time.time() # Returns ~0.0
|
127
|
+
return 0.0 # Returns ~0.0
|
130
128
|
|
131
129
|
def _suggest_smaller_instance_type(self, instance_type: str) -> Optional[str]:
|
132
130
|
"""
|
@@ -48,22 +48,24 @@ def common_output_options(f: Callable) -> Callable:
|
|
48
48
|
Standard output options for all runbooks commands.
|
49
49
|
|
50
50
|
Provides consistent output formatting and export options:
|
51
|
-
- --output-format: JSON, CSV, table, PDF output formats
|
51
|
+
- -f, --format, --output-format: JSON, CSV, table, PDF output formats (triple alias)
|
52
52
|
- --output-dir: Output directory for generated files
|
53
53
|
- --export: Enable multi-format export capability
|
54
54
|
|
55
55
|
Usage:
|
56
56
|
@common_output_options
|
57
57
|
@click.command()
|
58
|
-
def my_command(
|
59
|
-
# Your command logic here
|
58
|
+
def my_command(format, output_dir, export, **kwargs):
|
59
|
+
# Your command logic here (parameter name is 'format')
|
60
60
|
"""
|
61
61
|
|
62
62
|
@click.option(
|
63
|
+
"-f",
|
64
|
+
"--format",
|
63
65
|
"--output-format",
|
64
66
|
type=click.Choice(["json", "csv", "table", "pdf", "markdown"], case_sensitive=False),
|
65
67
|
default="table",
|
66
|
-
help="Output format for results display",
|
68
|
+
help="Output format for results display (-f/--format preferred, --output-format legacy)",
|
67
69
|
)
|
68
70
|
@click.option(
|
69
71
|
"--output-dir",
|