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
@@ -818,10 +818,13 @@ class LoadBalancerOptimizer:
|
|
818
818
|
@click.option("--regions", multiple=True, help="AWS regions to analyze (space-separated)")
|
819
819
|
@click.option("--dry-run/--no-dry-run", default=True, help="Execute in dry-run mode (READ-ONLY analysis)")
|
820
820
|
@click.option(
|
821
|
-
"
|
821
|
+
"-f", "--format", "--export-format",
|
822
|
+
type=click.Choice(["json", "csv", "markdown"]),
|
823
|
+
default="json",
|
824
|
+
help="Export format for results (-f/--format preferred, --export-format legacy)"
|
822
825
|
)
|
823
826
|
@click.option("--output-file", help="Output file path for results export")
|
824
|
-
def load_balancer_optimizer(profile, regions, dry_run,
|
827
|
+
def load_balancer_optimizer(profile, regions, dry_run, format, output_file):
|
825
828
|
"""
|
826
829
|
Load Balancer Cost Optimizer - Epic 2 Infrastructure Optimization
|
827
830
|
|
@@ -842,8 +845,8 @@ def load_balancer_optimizer(profile, regions, dry_run, export_format, output_fil
|
|
842
845
|
results = asyncio.run(optimizer.analyze_load_balancers(dry_run=dry_run))
|
843
846
|
|
844
847
|
# Export results if requested (implementation would go here)
|
845
|
-
if output_file or
|
846
|
-
print_info(f"Export functionality available - results ready for {
|
848
|
+
if output_file or format != "json":
|
849
|
+
print_info(f"Export functionality available - results ready for {format} export")
|
847
850
|
|
848
851
|
# Display final success message
|
849
852
|
if results.potential_annual_savings > 0:
|
@@ -784,10 +784,13 @@ class VPCEndpointOptimizer:
|
|
784
784
|
@click.option("--regions", multiple=True, help="AWS regions to analyze (space-separated)")
|
785
785
|
@click.option("--dry-run/--no-dry-run", default=True, help="Execute in dry-run mode (READ-ONLY analysis)")
|
786
786
|
@click.option(
|
787
|
-
"
|
787
|
+
"-f", "--format", "--export-format",
|
788
|
+
type=click.Choice(["json", "csv", "markdown"]),
|
789
|
+
default="json",
|
790
|
+
help="Export format for results (-f/--format preferred, --export-format legacy)"
|
788
791
|
)
|
789
792
|
@click.option("--output-file", help="Output file path for results export")
|
790
|
-
def vpc_endpoint_optimizer(profile, regions, dry_run,
|
793
|
+
def vpc_endpoint_optimizer(profile, regions, dry_run, format, output_file):
|
791
794
|
"""
|
792
795
|
VPC Endpoint Cost Optimizer - Epic 2 Infrastructure Optimization
|
793
796
|
|
@@ -808,8 +811,8 @@ def vpc_endpoint_optimizer(profile, regions, dry_run, export_format, output_file
|
|
808
811
|
results = asyncio.run(optimizer.analyze_vpc_endpoints(dry_run=dry_run))
|
809
812
|
|
810
813
|
# Export results if requested (implementation would go here)
|
811
|
-
if output_file or
|
812
|
-
print_info(f"Export functionality available - results ready for {
|
814
|
+
if output_file or format != "json":
|
815
|
+
print_info(f"Export functionality available - results ready for {format} export")
|
813
816
|
|
814
817
|
# Display final success message
|
815
818
|
if results.potential_annual_savings > 0:
|
@@ -1632,7 +1632,10 @@ To customize pricing:
|
|
1632
1632
|
@click.option("--force", is_flag=True, default=False, help="Required with --no-dry-run for destructive actions")
|
1633
1633
|
@click.option("--execute", is_flag=True, default=False, help="Execute optimization actions after analysis")
|
1634
1634
|
@click.option(
|
1635
|
-
"
|
1635
|
+
"-f", "--format", "--export-format",
|
1636
|
+
type=click.Choice(["json", "csv", "markdown"]),
|
1637
|
+
default="json",
|
1638
|
+
help="Export format for results (-f/--format preferred, --export-format legacy)"
|
1636
1639
|
)
|
1637
1640
|
@click.option("--output-file", help="Output file path for results export")
|
1638
1641
|
@click.option("--usage-threshold-days", type=int, default=7, help="CloudWatch analysis period in days")
|
@@ -1640,7 +1643,7 @@ To customize pricing:
|
|
1640
1643
|
"--show-pricing-config", is_flag=True, default=False, help="Display dynamic pricing configuration status and exit"
|
1641
1644
|
)
|
1642
1645
|
def nat_gateway_optimizer(
|
1643
|
-
profile, regions, dry_run, force, execute,
|
1646
|
+
profile, regions, dry_run, force, execute, format, output_file, usage_threshold_days, show_pricing_config
|
1644
1647
|
):
|
1645
1648
|
"""
|
1646
1649
|
NAT Gateway Cost Optimizer - Enterprise Multi-Region Analysis & Execution
|
@@ -1708,7 +1711,7 @@ def nat_gateway_optimizer(
|
|
1708
1711
|
print_success(f"💰 Actual savings achieved: {format_cost(actual_savings * 12)} annually")
|
1709
1712
|
|
1710
1713
|
# Step 3: Export results if requested
|
1711
|
-
if output_file or
|
1714
|
+
if output_file or format != "json":
|
1712
1715
|
export_data = results
|
1713
1716
|
if execution_results:
|
1714
1717
|
# Include execution results in export
|
@@ -1722,7 +1725,7 @@ def nat_gateway_optimizer(
|
|
1722
1725
|
|
1723
1726
|
export_data = ExtendedResults()
|
1724
1727
|
|
1725
|
-
optimizer.export_results(export_data, output_file,
|
1728
|
+
optimizer.export_results(export_data, output_file, format)
|
1726
1729
|
|
1727
1730
|
# Step 4: Display final success message
|
1728
1731
|
if execute and execution_results:
|
@@ -181,7 +181,7 @@ def run_module_exports_test():
|
|
181
181
|
# Test version number
|
182
182
|
from runbooks.finops import __version__
|
183
183
|
|
184
|
-
assert __version__ == "
|
184
|
+
assert __version__ == "1.1.9"
|
185
185
|
print(f" ✅ Version {__version__} correct")
|
186
186
|
|
187
187
|
print("✅ Module exports test passed\n")
|
@@ -16,9 +16,9 @@ How to use:
|
|
16
16
|
|
17
17
|
"""
|
18
18
|
|
19
|
-
__version__ = "2024.09.24"
|
20
19
|
|
21
20
|
import os
|
21
|
+
from runbooks import __version__
|
22
22
|
|
23
23
|
|
24
24
|
class CommonArguments:
|
@@ -197,6 +197,7 @@ class CommonArguments:
|
|
197
197
|
self.my_parser.add_argument(
|
198
198
|
"-p",
|
199
199
|
"-ps",
|
200
|
+
"--profile",
|
200
201
|
"--profiles",
|
201
202
|
dest="Profiles",
|
202
203
|
nargs="*",
|
runbooks/inventory/README.md
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
# AWS Multi-Account Discovery & Inventory (CLI)
|
2
2
|
|
3
|
-
**Version**: v1.1.
|
4
|
-
**Updated**: October
|
3
|
+
**Version**: v1.1.x (Modern CLI + 5-Phase MCP Validation)
|
4
|
+
**Updated**: October 12, 2025
|
5
5
|
|
6
6
|
The AWS Multi-Account Discovery module is an enterprise-grade command-line tool for comprehensive AWS resource discovery across 50+ services. Built with the Rich library for beautiful terminal output, it provides multi-threaded inventory collection with enterprise-grade error handling and reporting.
|
7
7
|
|
8
|
-
## 🆕 What's New in v1.1.
|
8
|
+
## 🆕 What's New in v1.1.x
|
9
9
|
|
10
10
|
**Complete CLI Parameters** (Zero Documentation-Reality Gaps):
|
11
11
|
- ✅ **12 functional parameters**: --dry-run, --status, --root-only, --short, --acct, --skip-profiles, -v, --timing, --save, --filename
|
12
12
|
- ✅ **Unified architecture**: Legacy script parameters migrated to modern CLI
|
13
|
-
- ✅ **Mode 4 validation**: Automated documentation accuracy testing (prevents
|
13
|
+
- ✅ **Mode 4 validation**: Automated documentation accuracy testing (prevents regression failures)
|
14
14
|
- ✅ **5-phase MCP reliability**: Timeout control, circuit breaker, error handling, retry logic, parallel safety
|
15
15
|
|
16
16
|
**Quality Achievement**:
|
17
17
|
- 96.3% QA score (26/27 checks passed)
|
18
|
-
- Zero regressions from
|
18
|
+
- Zero regressions from previous versions
|
19
19
|
- 100% QUICK-START command accuracy
|
20
20
|
|
21
21
|
**Complete Parameter Reference**: See `docs/INVENTORY-PARAMETERS.md` for comprehensive parameter documentation.
|
22
22
|
|
23
|
-
## ⚡ Performance Characteristics (v1.1.
|
23
|
+
## ⚡ Performance Characteristics (v1.1.x)
|
24
24
|
|
25
25
|
**Optimized Operation Timings**:
|
26
26
|
|
27
|
-
| Operation Type | Target | Actual (v1.1.
|
27
|
+
| Operation Type | Target | Actual (v1.1.x) | Optimization |
|
28
28
|
|----------------|--------|-----------------|--------------|
|
29
29
|
| Standard operations | <30s | 3.0s | ✅ 90% improvement |
|
30
30
|
| Quick operations (--dry-run, --short) | <5s | 1.5s | ✅ Enterprise target |
|
@@ -77,9 +77,36 @@ This collection provides comprehensive AWS inventory and management scripts foll
|
|
77
77
|
|
78
78
|
>**Note:** Scripts support both profile-based and federated authentication models. Enhanced SSO credential handling implemented.
|
79
79
|
|
80
|
-
## Modern CLI
|
80
|
+
## Modern CLI Interface (v1.1.x)
|
81
81
|
|
82
|
-
|
82
|
+
### Unified Inventory Commands
|
83
|
+
|
84
|
+
All 46 inventory scripts are accessible via a unified CLI interface:
|
85
|
+
|
86
|
+
```bash
|
87
|
+
# Modern interface (recommended)
|
88
|
+
runbooks inventory collect [OPTIONS]
|
89
|
+
runbooks inventory draw-org [OPTIONS]
|
90
|
+
runbooks inventory list-ec2-instances [OPTIONS]
|
91
|
+
|
92
|
+
# Legacy interface (still supported)
|
93
|
+
python src/runbooks/inventory/list_ec2_instances.py --profile X
|
94
|
+
```
|
95
|
+
|
96
|
+
### Parameter Standardization Table
|
97
|
+
|
98
|
+
| Legacy Script Parameter | Modern CLI Parameter | Description | Migration Notes |
|
99
|
+
|------------------------|---------------------|-------------|-----------------|
|
100
|
+
| `-p, --profile` | `--profile` | AWS profile name | Group-level parameter |
|
101
|
+
| `-v, -vv, -vvv, -d` | `--verbose, -v` | Logging verbosity | Simplified to single flag |
|
102
|
+
| `-f, --fragment` | `--fragment` | Resource name filter | Consistent naming |
|
103
|
+
| `--exact` | `--exact` | Exact fragment matching | No change |
|
104
|
+
| `--delete` | `--dry-run / --execute` | Execution mode | Safety-first approach |
|
105
|
+
| `-r, -rs, --regions` | `--region, --regions` | Target AWS regions | Standardized plural form |
|
106
|
+
| `--skipprofile` | `--skip-profiles` | Exclude specific profiles | Plural form consistency |
|
107
|
+
| `--skipaccount` | `--acct` (negative filter) | Exclude specific accounts | Integrated with --acct |
|
108
|
+
| `--filename` | `--save` | Output file path | More intuitive naming |
|
109
|
+
| `-h, --help` | `--help` | Display help information | No change |
|
83
110
|
|
84
111
|
### Core Parameters
|
85
112
|
|
@@ -116,11 +143,75 @@ This collection provides comprehensive AWS inventory and management scripts foll
|
|
116
143
|
|
117
144
|
**Complete Parameter Reference**: See `docs/INVENTORY-PARAMETERS.md` for detailed documentation with examples and troubleshooting.
|
118
145
|
|
146
|
+
## Organizations Visualization (draw-org)
|
147
|
+
|
148
|
+
### Modern CLI Interface Example
|
149
|
+
|
150
|
+
The `draw-org` command demonstrates the Modern CLI approach with multiple output formats and rich functionality:
|
151
|
+
|
152
|
+
```bash
|
153
|
+
# Basic organization diagram (Graphviz format)
|
154
|
+
runbooks inventory --profile $MANAGEMENT_PROFILE draw-org
|
155
|
+
|
156
|
+
# Include policies and AWS-managed SCPs
|
157
|
+
runbooks inventory --profile $MANAGEMENT_PROFILE draw-org --policy --show-aws-managed
|
158
|
+
|
159
|
+
# Mermaid format for documentation/wikis
|
160
|
+
runbooks inventory draw-org --profile $MANAGEMENT_PROFILE --format mermaid --timing
|
161
|
+
|
162
|
+
# Start from specific OU (focus on subset)
|
163
|
+
runbooks inventory draw-org --profile $MANAGEMENT_PROFILE --ou ou-1234567890 --format diagrams
|
164
|
+
```
|
165
|
+
|
166
|
+
### Output Formats
|
167
|
+
|
168
|
+
| Format | Use Case | Output Type | Best For |
|
169
|
+
|--------|----------|-------------|----------|
|
170
|
+
| **Graphviz** (default) | Visual diagrams | PNG image | Executive presentations |
|
171
|
+
| **Mermaid** | Documentation | Markdown text | Technical wikis, GitHub |
|
172
|
+
| **Diagrams** | Professional layouts | PNG/SVG | Architecture reviews |
|
173
|
+
|
174
|
+
### Required AWS Permissions
|
175
|
+
|
176
|
+
```json
|
177
|
+
{
|
178
|
+
"Version": "2012-10-17",
|
179
|
+
"Statement": [
|
180
|
+
{
|
181
|
+
"Effect": "Allow",
|
182
|
+
"Action": [
|
183
|
+
"organizations:List*",
|
184
|
+
"organizations:Describe*"
|
185
|
+
],
|
186
|
+
"Resource": "*"
|
187
|
+
}
|
188
|
+
]
|
189
|
+
}
|
190
|
+
```
|
191
|
+
|
192
|
+
### Parameter Comparison (draw-org Pilot)
|
193
|
+
|
194
|
+
| Feature | Legacy Script | Modern CLI | Improvement |
|
195
|
+
|---------|--------------|------------|-------------|
|
196
|
+
| **Profile handling** | `-p PROFILE` | `--profile PROFILE` (group-level) | Consistent with unified CLI |
|
197
|
+
| **Output format** | Graphviz only | `--format graphviz\|mermaid\|diagrams` | Multi-format support |
|
198
|
+
| **Policy display** | `--policy` | `--policy --show-aws-managed` | Granular control |
|
199
|
+
| **OU filtering** | Not supported | `--ou ou-XXXXXXXXXX` | Focused visualization |
|
200
|
+
| **Performance** | No metrics | `--timing` flag | Execution time tracking |
|
201
|
+
| **Verbosity** | `-v, -vv, -vvv` | `--verbose, -v` | Simplified logging |
|
202
|
+
|
119
203
|
## Legacy Script Migration
|
120
204
|
|
205
|
+
### Backward Compatibility Notice
|
206
|
+
|
207
|
+
Both invocation methods are supported during the transition period:
|
208
|
+
|
209
|
+
- **Modern CLI** (recommended): `runbooks inventory <command> [OPTIONS]`
|
210
|
+
- **Direct Script** (legacy): `python src/runbooks/inventory/<script>.py [OPTIONS]`
|
211
|
+
|
121
212
|
**Legacy Pattern** (46 individual scripts):
|
122
213
|
```bash
|
123
|
-
# Old approach (v1.1.
|
214
|
+
# Old approach (pre-v1.1.x)
|
124
215
|
python list_ec2_instances.py -p production -r us-east-1 -v
|
125
216
|
python list_rds_db_instances.py -p production -r us-east-1 -v
|
126
217
|
python list_vpcs.py -p production -r us-east-1
|
@@ -128,7 +219,7 @@ python list_vpcs.py -p production -r us-east-1
|
|
128
219
|
|
129
220
|
**Modern CLI Pattern** (unified interface):
|
130
221
|
```bash
|
131
|
-
# New approach (v1.1.
|
222
|
+
# New approach (v1.1.x recommended)
|
132
223
|
runbooks inventory collect --profile production --regions us-east-1 --resources ec2,rds,vpc -v
|
133
224
|
|
134
225
|
# Even simpler (all resources)
|
@@ -138,10 +229,18 @@ runbooks inventory collect --profile production --regions us-east-1 -v
|
|
138
229
|
**Benefits**:
|
139
230
|
- ✅ **Single command** instead of 46 scripts
|
140
231
|
- ✅ **Consistent parameters** across all resource types
|
141
|
-
- ✅ **Rich terminal output** with
|
232
|
+
- ✅ **Rich terminal output** with colors and formatting
|
142
233
|
- ✅ **Performance tracking** via `--timing` parameter
|
143
234
|
- ✅ **Flexible output** via `--save` parameter
|
144
235
|
|
236
|
+
### Migration Timeline
|
237
|
+
|
238
|
+
| Version | Modern CLI | Legacy Scripts | Status |
|
239
|
+
|---------|-----------|----------------|---------|
|
240
|
+
| **v1.1.x - v1.2.x** | ✅ Recommended | ✅ Fully supported | Dual support period |
|
241
|
+
| **v1.3.x+** | ✅ Primary | ⚠️ Deprecation warnings | Transition phase |
|
242
|
+
| **v2.0.x** | ✅ Only | ❌ Removed | Modern CLI only |
|
243
|
+
|
145
244
|
## Common Parameters (Legacy Scripts)
|
146
245
|
|
147
246
|
> ***Note***: *The following parameters apply to legacy script execution. For modern CLI usage, see "Modern CLI Parameters" above.*
|
@@ -1,14 +1,31 @@
|
|
1
1
|
import pytest
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
|
3
|
+
# Legacy test for deprecated standalone scripts (pre-module refactoring)
|
4
|
+
# Module structure has replaced standalone scripts: runbooks.inventory.*
|
5
|
+
# Modern tests exist in tests/inventory/ for current module structure
|
6
|
+
pytestmark = pytest.mark.skip(reason="Legacy test for deprecated standalone Inventory_Modules script (pre-module refactoring)")
|
7
|
+
|
8
|
+
try:
|
9
|
+
from common_test_data import (
|
10
|
+
AssumeRoleResponseData,
|
11
|
+
DescribeOrganizationsResponseData,
|
12
|
+
DescribeRegionsResponseData,
|
13
|
+
GetCallerIdentity,
|
14
|
+
ListAccountsResponseData,
|
15
|
+
cli_provided_parameters1,
|
16
|
+
)
|
17
|
+
from common_test_functions import _amend_make_api_call
|
18
|
+
from Inventory_Modules import get_all_credentials
|
19
|
+
LEGACY_MODULES_AVAILABLE = True
|
20
|
+
except ImportError:
|
21
|
+
LEGACY_MODULES_AVAILABLE = False
|
22
|
+
# Dummy values to prevent NameError
|
23
|
+
AssumeRoleResponseData = None
|
24
|
+
DescribeOrganizationsResponseData = None
|
25
|
+
DescribeRegionsResponseData = None
|
26
|
+
GetCallerIdentity = None
|
27
|
+
ListAccountsResponseData = None
|
28
|
+
cli_provided_parameters1 = None
|
12
29
|
|
13
30
|
get_all_credentials_test_result_dict = [
|
14
31
|
{"operation_name": "GetCallerIdentity", "test_result": GetCallerIdentity},
|
@@ -6,14 +6,25 @@ from unittest.mock import MagicMock, patch
|
|
6
6
|
|
7
7
|
import pytest
|
8
8
|
|
9
|
+
# Legacy test for deprecated standalone scripts (pre-module refactoring)
|
10
|
+
# Module structure has replaced standalone scripts: runbooks.inventory.cloudformation.*
|
11
|
+
# Modern tests exist in tests/cloudformation/ for current module structure
|
12
|
+
pytestmark = pytest.mark.skip(reason="Legacy test for deprecated standalone cfn_describe_stacks script (pre-module refactoring)")
|
13
|
+
|
9
14
|
# Import the functions you want to test
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
try:
|
16
|
+
from cfn_describe_stacks import (
|
17
|
+
collect_cfnstacks,
|
18
|
+
display_stacks,
|
19
|
+
modify_stacks,
|
20
|
+
parse_args,
|
21
|
+
setup_auth_accounts_and_regions,
|
22
|
+
)
|
23
|
+
LEGACY_MODULES_AVAILABLE = True
|
24
|
+
except ImportError:
|
25
|
+
LEGACY_MODULES_AVAILABLE = False
|
26
|
+
# Dummy functions to prevent NameError
|
27
|
+
collect_cfnstacks = display_stacks = modify_stacks = parse_args = setup_auth_accounts_and_regions = None
|
17
28
|
|
18
29
|
|
19
30
|
class TestScriptFunctions(unittest.TestCase):
|
@@ -7,21 +7,36 @@ import unittest
|
|
7
7
|
from unittest.mock import patch
|
8
8
|
|
9
9
|
import pytest
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
10
|
+
|
11
|
+
# Legacy test for deprecated standalone scripts (pre-module refactoring)
|
12
|
+
# Module structure has replaced standalone scripts: runbooks.inventory.ec2.*
|
13
|
+
# Modern tests exist in tests/ec2/ for current module structure
|
14
|
+
pytestmark = pytest.mark.skip(reason="Legacy test for deprecated standalone ec2_describe_instances script (pre-module refactoring)")
|
15
|
+
|
16
|
+
try:
|
17
|
+
from common_test_data import (
|
18
|
+
All_Instances_Response_Data,
|
19
|
+
CredentialResponseData,
|
20
|
+
mock_instances_1,
|
21
|
+
mock_profile_list_1,
|
22
|
+
mock_profile_list_2,
|
23
|
+
mock_profile_list_3,
|
24
|
+
mock_profile_list_4,
|
25
|
+
mock_region_list_1,
|
26
|
+
mock_region_list_2,
|
27
|
+
mock_region_list_3,
|
28
|
+
mock_region_list_4,
|
29
|
+
)
|
30
|
+
from common_test_functions import mock_find_all_instances2
|
31
|
+
from ec2_describe_instances import find_all_instances, parse_args
|
32
|
+
LEGACY_MODULES_AVAILABLE = True
|
33
|
+
except ImportError:
|
34
|
+
LEGACY_MODULES_AVAILABLE = False
|
35
|
+
# Dummy values to prevent NameError
|
36
|
+
All_Instances_Response_Data = CredentialResponseData = mock_instances_1 = None
|
37
|
+
mock_profile_list_1 = mock_profile_list_2 = mock_profile_list_3 = mock_profile_list_4 = None
|
38
|
+
mock_region_list_1 = mock_region_list_2 = mock_region_list_3 = mock_region_list_4 = None
|
39
|
+
mock_find_all_instances2 = find_all_instances = parse_args = None
|
25
40
|
|
26
41
|
|
27
42
|
class TestScriptFunctions(unittest.TestCase):
|
@@ -1,7 +1,21 @@
|
|
1
1
|
import pytest
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
|
3
|
+
# Legacy test for deprecated standalone scripts (pre-module refactoring)
|
4
|
+
# Module structure has replaced standalone scripts: runbooks.inventory.lambda.*
|
5
|
+
# Modern tests exist in tests/lambda/ for current module structure
|
6
|
+
pytestmark = pytest.mark.skip(reason="Legacy test for deprecated standalone lambda_list_functions script (pre-module refactoring)")
|
7
|
+
|
8
|
+
try:
|
9
|
+
from common_test_data import CredentialResponseData, get_all_my_functions_test_result_dict
|
10
|
+
from common_test_functions import _amend_create_boto3_session, _amend_make_api_call, _amend_make_api_call_specific
|
11
|
+
from lambda_list_functions import collect_all_my_functions, fix_my_functions
|
12
|
+
LEGACY_MODULES_AVAILABLE = True
|
13
|
+
except ImportError:
|
14
|
+
LEGACY_MODULES_AVAILABLE = False
|
15
|
+
# Dummy values to prevent NameError
|
16
|
+
CredentialResponseData = get_all_my_functions_test_result_dict = None
|
17
|
+
_amend_create_boto3_session = _amend_make_api_call = _amend_make_api_call_specific = None
|
18
|
+
collect_all_my_functions = fix_my_functions = None
|
5
19
|
|
6
20
|
# CredentialList = test_get_all_credentials()
|
7
21
|
# This is what the response from the tested function should look like, given the parameters supplied
|
@@ -1,10 +1,23 @@
|
|
1
1
|
from datetime import datetime
|
2
2
|
|
3
3
|
import pytest
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
|
5
|
+
# Legacy test for deprecated standalone scripts (pre-module refactoring)
|
6
|
+
# Module structure has replaced standalone scripts: runbooks.inventory.organizations.*
|
7
|
+
# Modern tests exist in tests/organizations/ for current module structure
|
8
|
+
pytestmark = pytest.mark.skip(reason="Legacy test for deprecated standalone org_list_accounts script (pre-module refactoring)")
|
9
|
+
|
10
|
+
try:
|
11
|
+
from botocore import client
|
12
|
+
from common_test_data import cli_provided_parameters1, cli_provided_parameters2, get_all_my_orgs_test_result_dict
|
13
|
+
from common_test_functions import AWSAccount_from_AWSKeyID, _amend_make_api_call, _amend_make_api_call_orig
|
14
|
+
from org_list_accounts import all_my_orgs
|
15
|
+
LEGACY_MODULES_AVAILABLE = True
|
16
|
+
except ImportError:
|
17
|
+
LEGACY_MODULES_AVAILABLE = False
|
18
|
+
# Dummy values to prevent NameError
|
19
|
+
client = cli_provided_parameters1 = cli_provided_parameters2 = get_all_my_orgs_test_result_dict = None
|
20
|
+
AWSAccount_from_AWSKeyID = _amend_make_api_call = _amend_make_api_call_orig = all_my_orgs = None
|
8
21
|
|
9
22
|
|
10
23
|
@pytest.mark.parametrize(
|
@@ -93,12 +93,8 @@ def main():
|
|
93
93
|
# Parse command-line arguments with validation
|
94
94
|
args = parser.parse_args()
|
95
95
|
|
96
|
-
# Build command arguments for list_ec2_instances.py
|
97
|
-
|
98
|
-
import os
|
99
|
-
|
100
|
-
script_path = os.path.join(os.path.dirname(__file__), "list_ec2_instances.py")
|
101
|
-
cmd = [sys.executable, script_path]
|
96
|
+
# Build command arguments for list_ec2_instances.py using module execution
|
97
|
+
cmd = [sys.executable, "-m", "runbooks.inventory.list_ec2_instances"]
|
102
98
|
if args.profile:
|
103
99
|
cmd.extend(["--profile", args.profile])
|
104
100
|
if args.region:
|
@@ -108,14 +104,14 @@ def main():
|
|
108
104
|
|
109
105
|
# Execute the actual EC2 instance listing as subprocess
|
110
106
|
try:
|
111
|
-
result = subprocess.run(cmd, capture_output=True, text=True
|
107
|
+
result = subprocess.run(cmd, capture_output=True, text=True)
|
112
108
|
print(result.stdout)
|
113
109
|
if result.stderr:
|
114
110
|
print(result.stderr, file=sys.stderr)
|
115
111
|
print(f"\nWrapper completed successfully for account {args.account_id}")
|
116
112
|
sys.exit(result.returncode)
|
117
113
|
except Exception as e:
|
118
|
-
print(f"Error executing list_ec2_instances
|
114
|
+
print(f"Error executing list_ec2_instances: {e}")
|
119
115
|
sys.exit(1)
|
120
116
|
|
121
117
|
|
Binary file
|
@@ -130,13 +130,13 @@ from threading import Thread
|
|
130
130
|
from time import time
|
131
131
|
|
132
132
|
# import boto3
|
133
|
-
import Inventory_Modules
|
134
|
-
from ArgumentsClass import CommonArguments
|
133
|
+
from runbooks.inventory import inventory_modules as Inventory_Modules
|
134
|
+
from runbooks.inventory.ArgumentsClass import CommonArguments
|
135
135
|
from botocore.exceptions import ClientError
|
136
136
|
from runbooks.common.rich_utils import console
|
137
|
-
from
|
137
|
+
from runbooks.inventory.inventory_modules import display_results, get_all_credentials
|
138
|
+
from runbooks import __version__
|
138
139
|
|
139
|
-
__version__ = "2023.10.03"
|
140
140
|
|
141
141
|
|
142
142
|
##################
|