runbooks 0.2.5__py3-none-any.whl → 0.7.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.
- conftest.py +26 -0
- jupyter-agent/.env +2 -0
- jupyter-agent/.env.template +2 -0
- jupyter-agent/.gitattributes +35 -0
- jupyter-agent/.gradio/certificate.pem +31 -0
- jupyter-agent/README.md +16 -0
- jupyter-agent/__main__.log +8 -0
- jupyter-agent/app.py +256 -0
- jupyter-agent/cloudops-agent.png +0 -0
- jupyter-agent/ds-system-prompt.txt +154 -0
- jupyter-agent/jupyter-agent.png +0 -0
- jupyter-agent/llama3_template.jinja +123 -0
- jupyter-agent/requirements.txt +9 -0
- jupyter-agent/tmp/4ojbs8a02ir/jupyter-agent.ipynb +68 -0
- jupyter-agent/tmp/cm5iasgpm3p/jupyter-agent.ipynb +91 -0
- jupyter-agent/tmp/crqbsseag5/jupyter-agent.ipynb +91 -0
- jupyter-agent/tmp/hohanq1u097/jupyter-agent.ipynb +57 -0
- jupyter-agent/tmp/jns1sam29wm/jupyter-agent.ipynb +53 -0
- jupyter-agent/tmp/jupyter-agent.ipynb +27 -0
- jupyter-agent/utils.py +409 -0
- runbooks/__init__.py +71 -3
- runbooks/__main__.py +13 -0
- runbooks/aws/ec2_describe_instances.py +1 -1
- runbooks/aws/ec2_run_instances.py +8 -2
- runbooks/aws/ec2_start_stop_instances.py +17 -4
- runbooks/aws/ec2_unused_volumes.py +5 -1
- runbooks/aws/s3_create_bucket.py +4 -2
- runbooks/aws/s3_list_objects.py +6 -1
- runbooks/aws/tagging_lambda_handler.py +13 -2
- runbooks/aws/tags.json +12 -0
- runbooks/base.py +353 -0
- runbooks/cfat/README.md +49 -0
- runbooks/cfat/__init__.py +74 -0
- runbooks/cfat/app.ts +644 -0
- runbooks/cfat/assessment/__init__.py +40 -0
- runbooks/cfat/assessment/asana-import.csv +39 -0
- runbooks/cfat/assessment/cfat-checks.csv +31 -0
- runbooks/cfat/assessment/cfat.txt +520 -0
- runbooks/cfat/assessment/collectors.py +200 -0
- runbooks/cfat/assessment/jira-import.csv +39 -0
- runbooks/cfat/assessment/runner.py +387 -0
- runbooks/cfat/assessment/validators.py +290 -0
- runbooks/cfat/cli.py +103 -0
- runbooks/cfat/docs/asana-import.csv +24 -0
- runbooks/cfat/docs/cfat-checks.csv +31 -0
- runbooks/cfat/docs/cfat.txt +335 -0
- runbooks/cfat/docs/checks-output.png +0 -0
- runbooks/cfat/docs/cloudshell-console-run.png +0 -0
- runbooks/cfat/docs/cloudshell-download.png +0 -0
- runbooks/cfat/docs/cloudshell-output.png +0 -0
- runbooks/cfat/docs/downloadfile.png +0 -0
- runbooks/cfat/docs/jira-import.csv +24 -0
- runbooks/cfat/docs/open-cloudshell.png +0 -0
- runbooks/cfat/docs/report-header.png +0 -0
- runbooks/cfat/models.py +1026 -0
- runbooks/cfat/package-lock.json +5116 -0
- runbooks/cfat/package.json +38 -0
- runbooks/cfat/report.py +496 -0
- runbooks/cfat/reporting/__init__.py +46 -0
- runbooks/cfat/reporting/exporters.py +337 -0
- runbooks/cfat/reporting/formatters.py +496 -0
- runbooks/cfat/reporting/templates.py +135 -0
- runbooks/cfat/run-assessment.sh +23 -0
- runbooks/cfat/runner.py +69 -0
- runbooks/cfat/src/actions/check-cloudtrail-existence.ts +43 -0
- runbooks/cfat/src/actions/check-config-existence.ts +37 -0
- runbooks/cfat/src/actions/check-control-tower.ts +37 -0
- runbooks/cfat/src/actions/check-ec2-existence.ts +46 -0
- runbooks/cfat/src/actions/check-iam-users.ts +50 -0
- runbooks/cfat/src/actions/check-legacy-cur.ts +30 -0
- runbooks/cfat/src/actions/check-org-cloudformation.ts +30 -0
- runbooks/cfat/src/actions/check-vpc-existence.ts +43 -0
- runbooks/cfat/src/actions/create-asanaimport.ts +14 -0
- runbooks/cfat/src/actions/create-backlog.ts +372 -0
- runbooks/cfat/src/actions/create-jiraimport.ts +15 -0
- runbooks/cfat/src/actions/create-report.ts +616 -0
- runbooks/cfat/src/actions/define-account-type.ts +51 -0
- runbooks/cfat/src/actions/get-enabled-org-policy-types.ts +40 -0
- runbooks/cfat/src/actions/get-enabled-org-services.ts +26 -0
- runbooks/cfat/src/actions/get-idc-info.ts +34 -0
- runbooks/cfat/src/actions/get-org-da-accounts.ts +34 -0
- runbooks/cfat/src/actions/get-org-details.ts +35 -0
- runbooks/cfat/src/actions/get-org-member-accounts.ts +44 -0
- runbooks/cfat/src/actions/get-org-ous.ts +35 -0
- runbooks/cfat/src/actions/get-regions.ts +22 -0
- runbooks/cfat/src/actions/zip-assessment.ts +27 -0
- runbooks/cfat/src/types/index.d.ts +147 -0
- runbooks/cfat/tests/__init__.py +141 -0
- runbooks/cfat/tests/test_cli.py +340 -0
- runbooks/cfat/tests/test_integration.py +290 -0
- runbooks/cfat/tests/test_models.py +505 -0
- runbooks/cfat/tests/test_reporting.py +354 -0
- runbooks/cfat/tsconfig.json +16 -0
- runbooks/cfat/webpack.config.cjs +27 -0
- runbooks/config.py +260 -0
- runbooks/finops/README.md +337 -0
- runbooks/finops/__init__.py +86 -0
- runbooks/finops/aws_client.py +245 -0
- runbooks/finops/cli.py +151 -0
- runbooks/finops/cost_processor.py +410 -0
- runbooks/finops/dashboard_runner.py +448 -0
- runbooks/finops/helpers.py +355 -0
- runbooks/finops/main.py +14 -0
- runbooks/finops/profile_processor.py +174 -0
- runbooks/finops/types.py +66 -0
- runbooks/finops/visualisations.py +80 -0
- runbooks/inventory/.gitignore +354 -0
- runbooks/inventory/ArgumentsClass.py +261 -0
- runbooks/inventory/FAILED_SCRIPTS_TROUBLESHOOTING.md +619 -0
- runbooks/inventory/Inventory_Modules.py +6130 -0
- runbooks/inventory/LandingZone/delete_lz.py +1075 -0
- runbooks/inventory/PASSED_SCRIPTS_GUIDE.md +738 -0
- runbooks/inventory/README.md +1320 -0
- runbooks/inventory/__init__.py +62 -0
- runbooks/inventory/account_class.py +532 -0
- runbooks/inventory/all_my_instances_wrapper.py +123 -0
- runbooks/inventory/aws_decorators.py +201 -0
- runbooks/inventory/aws_organization.png +0 -0
- runbooks/inventory/cfn_move_stack_instances.py +1526 -0
- runbooks/inventory/check_cloudtrail_compliance.py +614 -0
- runbooks/inventory/check_controltower_readiness.py +1107 -0
- runbooks/inventory/check_landingzone_readiness.py +711 -0
- runbooks/inventory/cloudtrail.md +727 -0
- runbooks/inventory/collectors/__init__.py +20 -0
- runbooks/inventory/collectors/aws_compute.py +518 -0
- runbooks/inventory/collectors/aws_networking.py +275 -0
- runbooks/inventory/collectors/base.py +222 -0
- runbooks/inventory/core/__init__.py +19 -0
- runbooks/inventory/core/collector.py +303 -0
- runbooks/inventory/core/formatter.py +296 -0
- runbooks/inventory/delete_s3_buckets_objects.py +169 -0
- runbooks/inventory/discovery.md +81 -0
- runbooks/inventory/draw_org_structure.py +748 -0
- runbooks/inventory/ec2_vpc_utils.py +341 -0
- runbooks/inventory/find_cfn_drift_detection.py +272 -0
- runbooks/inventory/find_cfn_orphaned_stacks.py +719 -0
- runbooks/inventory/find_cfn_stackset_drift.py +733 -0
- runbooks/inventory/find_ec2_security_groups.py +669 -0
- runbooks/inventory/find_landingzone_versions.py +201 -0
- runbooks/inventory/find_vpc_flow_logs.py +1221 -0
- runbooks/inventory/inventory.sh +659 -0
- runbooks/inventory/list_cfn_stacks.py +558 -0
- runbooks/inventory/list_cfn_stackset_operation_results.py +252 -0
- runbooks/inventory/list_cfn_stackset_operations.py +734 -0
- runbooks/inventory/list_cfn_stacksets.py +453 -0
- runbooks/inventory/list_config_recorders_delivery_channels.py +681 -0
- runbooks/inventory/list_ds_directories.py +354 -0
- runbooks/inventory/list_ec2_availability_zones.py +286 -0
- runbooks/inventory/list_ec2_ebs_volumes.py +244 -0
- runbooks/inventory/list_ec2_instances.py +425 -0
- runbooks/inventory/list_ecs_clusters_and_tasks.py +562 -0
- runbooks/inventory/list_elbs_load_balancers.py +411 -0
- runbooks/inventory/list_enis_network_interfaces.py +526 -0
- runbooks/inventory/list_guardduty_detectors.py +568 -0
- runbooks/inventory/list_iam_policies.py +404 -0
- runbooks/inventory/list_iam_roles.py +518 -0
- runbooks/inventory/list_iam_saml_providers.py +359 -0
- runbooks/inventory/list_lambda_functions.py +882 -0
- runbooks/inventory/list_org_accounts.py +446 -0
- runbooks/inventory/list_org_accounts_users.py +354 -0
- runbooks/inventory/list_rds_db_instances.py +406 -0
- runbooks/inventory/list_route53_hosted_zones.py +318 -0
- runbooks/inventory/list_servicecatalog_provisioned_products.py +575 -0
- runbooks/inventory/list_sns_topics.py +360 -0
- runbooks/inventory/list_ssm_parameters.py +402 -0
- runbooks/inventory/list_vpc_subnets.py +433 -0
- runbooks/inventory/list_vpcs.py +422 -0
- runbooks/inventory/lockdown_cfn_stackset_role.py +224 -0
- runbooks/inventory/models/__init__.py +24 -0
- runbooks/inventory/models/account.py +192 -0
- runbooks/inventory/models/inventory.py +309 -0
- runbooks/inventory/models/resource.py +247 -0
- runbooks/inventory/recover_cfn_stack_ids.py +205 -0
- runbooks/inventory/requirements.txt +12 -0
- runbooks/inventory/run_on_multi_accounts.py +211 -0
- runbooks/inventory/tests/common_test_data.py +3661 -0
- runbooks/inventory/tests/common_test_functions.py +204 -0
- runbooks/inventory/tests/setup.py +24 -0
- runbooks/inventory/tests/src.py +18 -0
- runbooks/inventory/tests/test_cfn_describe_stacks.py +208 -0
- runbooks/inventory/tests/test_ec2_describe_instances.py +162 -0
- runbooks/inventory/tests/test_inventory_modules.py +55 -0
- runbooks/inventory/tests/test_lambda_list_functions.py +86 -0
- runbooks/inventory/tests/test_moto_integration_example.py +273 -0
- runbooks/inventory/tests/test_org_list_accounts.py +49 -0
- runbooks/inventory/update_aws_actions.py +173 -0
- runbooks/inventory/update_cfn_stacksets.py +1215 -0
- runbooks/inventory/update_cloudwatch_logs_retention_policy.py +294 -0
- runbooks/inventory/update_iam_roles_cross_accounts.py +478 -0
- runbooks/inventory/update_s3_public_access_block.py +539 -0
- runbooks/inventory/utils/__init__.py +23 -0
- runbooks/inventory/utils/aws_helpers.py +510 -0
- runbooks/inventory/utils/threading_utils.py +493 -0
- runbooks/inventory/utils/validation.py +682 -0
- runbooks/inventory/verify_ec2_security_groups.py +1430 -0
- runbooks/main.py +1004 -0
- runbooks/organizations/__init__.py +12 -0
- runbooks/organizations/manager.py +374 -0
- runbooks/security/README.md +447 -0
- runbooks/security/__init__.py +71 -0
- runbooks/{security_baseline → security}/checklist/alternate_contacts.py +8 -1
- runbooks/{security_baseline → security}/checklist/bucket_public_access.py +4 -1
- runbooks/{security_baseline → security}/checklist/cloudwatch_alarm_configuration.py +9 -2
- runbooks/{security_baseline → security}/checklist/guardduty_enabled.py +9 -2
- runbooks/{security_baseline → security}/checklist/multi_region_instance_usage.py +5 -1
- runbooks/{security_baseline → security}/checklist/root_access_key.py +6 -1
- runbooks/{security_baseline → security}/config-origin.json +1 -1
- runbooks/{security_baseline → security}/config.json +1 -1
- runbooks/{security_baseline → security}/permission.json +1 -1
- runbooks/{security_baseline → security}/report_generator.py +10 -2
- runbooks/{security_baseline → security}/report_template_en.html +7 -7
- runbooks/{security_baseline → security}/report_template_jp.html +7 -7
- runbooks/{security_baseline → security}/report_template_kr.html +12 -12
- runbooks/{security_baseline → security}/report_template_vn.html +7 -7
- runbooks/{security_baseline → security}/run_script.py +8 -2
- runbooks/{security_baseline → security}/security_baseline_tester.py +12 -4
- runbooks/{security_baseline → security}/utils/common.py +5 -1
- runbooks/utils/__init__.py +204 -0
- runbooks-0.7.0.dist-info/METADATA +375 -0
- runbooks-0.7.0.dist-info/RECORD +249 -0
- {runbooks-0.2.5.dist-info → runbooks-0.7.0.dist-info}/WHEEL +1 -1
- runbooks-0.7.0.dist-info/entry_points.txt +7 -0
- runbooks-0.7.0.dist-info/licenses/LICENSE +201 -0
- runbooks-0.7.0.dist-info/top_level.txt +3 -0
- runbooks/python101/calculator.py +0 -34
- runbooks/python101/config.py +0 -1
- runbooks/python101/exceptions.py +0 -16
- runbooks/python101/file_manager.py +0 -218
- runbooks/python101/toolkit.py +0 -153
- runbooks-0.2.5.dist-info/METADATA +0 -439
- runbooks-0.2.5.dist-info/RECORD +0 -61
- runbooks-0.2.5.dist-info/entry_points.txt +0 -3
- runbooks-0.2.5.dist-info/top_level.txt +0 -1
- /runbooks/{security_baseline/__init__.py → inventory/tests/script_test_data.py} +0 -0
- /runbooks/{security_baseline → security}/checklist/__init__.py +0 -0
- /runbooks/{security_baseline → security}/checklist/account_level_bucket_public_access.py +0 -0
- /runbooks/{security_baseline → security}/checklist/direct_attached_policy.py +0 -0
- /runbooks/{security_baseline → security}/checklist/iam_password_policy.py +0 -0
- /runbooks/{security_baseline → security}/checklist/iam_user_mfa.py +0 -0
- /runbooks/{security_baseline → security}/checklist/multi_region_trail.py +0 -0
- /runbooks/{security_baseline → security}/checklist/root_mfa.py +0 -0
- /runbooks/{security_baseline → security}/checklist/root_usage.py +0 -0
- /runbooks/{security_baseline → security}/checklist/trail_enabled.py +0 -0
- /runbooks/{security_baseline → security}/checklist/trusted_advisor.py +0 -0
- /runbooks/{security_baseline → security}/utils/__init__.py +0 -0
- /runbooks/{security_baseline → security}/utils/enums.py +0 -0
- /runbooks/{security_baseline → security}/utils/language.py +0 -0
- /runbooks/{security_baseline → security}/utils/level_const.py +0 -0
- /runbooks/{security_baseline → security}/utils/permission_list.py +0 -0
@@ -0,0 +1,201 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
AWS Landing Zone Version Discovery and Analysis Script
|
4
|
+
|
5
|
+
Comprehensive enterprise-grade tool for discovering, enumerating, and analyzing AWS Landing Zone
|
6
|
+
(ALZ) deployments across multiple AWS profiles and organizational environments. Designed for
|
7
|
+
enterprise infrastructure governance, compliance monitoring, and Landing Zone lifecycle management
|
8
|
+
with multi-profile authentication and automated version tracking capabilities.
|
9
|
+
|
10
|
+
Key Features:
|
11
|
+
- Multi-profile AWS Landing Zone discovery and version identification
|
12
|
+
- Automated Management Account detection through CloudFormation stack analysis
|
13
|
+
- Landing Zone solution version extraction from CloudFormation outputs
|
14
|
+
- Comprehensive tabular reporting with profile, account, region, and version details
|
15
|
+
- Enterprise authentication with multi-profile credential management
|
16
|
+
- Extensive error handling for credential and configuration issues
|
17
|
+
|
18
|
+
Enterprise Capabilities:
|
19
|
+
- Organizational Landing Zone inventory and lifecycle tracking
|
20
|
+
- Multi-environment Landing Zone version compliance monitoring
|
21
|
+
- Automated Management Account identification for governance operations
|
22
|
+
- Cross-profile Landing Zone deployment visibility and analysis
|
23
|
+
- Enterprise credential management with comprehensive error handling
|
24
|
+
- Scalable processing for large-scale multi-account environments
|
25
|
+
|
26
|
+
Operational Use Cases:
|
27
|
+
- Landing Zone version audit and compliance tracking across organizations
|
28
|
+
- Management Account discovery for organizational governance operations
|
29
|
+
- Infrastructure inventory for Landing Zone upgrade planning and coordination
|
30
|
+
- Enterprise compliance monitoring through systematic Landing Zone analysis
|
31
|
+
- Multi-environment Landing Zone deployment tracking and management
|
32
|
+
|
33
|
+
Output Format:
|
34
|
+
- Tabular display with Profile, Account, Region, Stack Name, and Version information
|
35
|
+
- Comprehensive operational metrics including profile count and Landing Zone discovery statistics
|
36
|
+
- Color-coded terminal output for enhanced operational visibility
|
37
|
+
- Structured data presentation for integration with enterprise reporting systems
|
38
|
+
|
39
|
+
Authentication & Security:
|
40
|
+
- Multi-profile AWS credential management with comprehensive validation
|
41
|
+
- Cross-account access through profile-based authentication
|
42
|
+
- Extensive error handling for credential retrieval and configuration issues
|
43
|
+
- Regional validation and access control for secure Landing Zone operations
|
44
|
+
|
45
|
+
Performance & Scale:
|
46
|
+
- Efficient multi-profile processing for large-scale organizational environments
|
47
|
+
- Memory-efficient CloudFormation stack analysis and version extraction
|
48
|
+
- Progress indicators for enhanced user experience during discovery operations
|
49
|
+
- Optimized API usage patterns for improved performance and reduced throttling
|
50
|
+
|
51
|
+
Landing Zone Detection Logic:
|
52
|
+
- CloudFormation stack analysis for Landing Zone identification (SO0044 solution)
|
53
|
+
- Stack description parsing for AWS Landing Zone solution identification
|
54
|
+
- Output key extraction for precise Landing Zone version determination
|
55
|
+
- Multi-stack analysis ensuring comprehensive Landing Zone discovery
|
56
|
+
|
57
|
+
Error Handling & Resilience:
|
58
|
+
- Comprehensive credential error handling with specific error type identification
|
59
|
+
- AWS API authorization failure detection with detailed troubleshooting guidance
|
60
|
+
- Configuration validation with profile-specific error messaging
|
61
|
+
- Graceful degradation for inaccessible profiles maintaining operation continuity
|
62
|
+
|
63
|
+
Dependencies:
|
64
|
+
- boto3: AWS SDK for CloudFormation and credential management
|
65
|
+
- Custom modules: Inventory_Modules, ArgumentsClass
|
66
|
+
- colorama: Enhanced terminal output and progress indicators
|
67
|
+
|
68
|
+
Authors: AWS CloudOps Team
|
69
|
+
Version: 2023.05.31
|
70
|
+
License: MIT
|
71
|
+
"""
|
72
|
+
|
73
|
+
import logging
|
74
|
+
|
75
|
+
import boto3
|
76
|
+
import Inventory_Modules
|
77
|
+
from ArgumentsClass import CommonArguments
|
78
|
+
from botocore.exceptions import ClientError, CredentialRetrievalError, InvalidConfigError
|
79
|
+
from colorama import init
|
80
|
+
|
81
|
+
# Initialize colorama for cross-platform colored terminal output
|
82
|
+
init()
|
83
|
+
|
84
|
+
__version__ = "2023.05.31"
|
85
|
+
|
86
|
+
# Configure comprehensive CLI argument parsing for Landing Zone discovery operations
|
87
|
+
parser = CommonArguments()
|
88
|
+
parser.multiprofile() # Multi-profile authentication for organizational Landing Zone discovery
|
89
|
+
parser.verbosity() # Configurable logging levels for operational visibility
|
90
|
+
parser.version(__version__) # Script version tracking for compatibility management
|
91
|
+
args = parser.my_parser.parse_args()
|
92
|
+
|
93
|
+
# Extract CLI arguments for Landing Zone discovery and operational configuration
|
94
|
+
pProfiles = args.Profiles # AWS profiles for multi-account Landing Zone analysis
|
95
|
+
verbose = args.loglevel # Logging verbosity for operational monitoring and troubleshooting
|
96
|
+
|
97
|
+
# Configure comprehensive logging for Landing Zone discovery operations
|
98
|
+
logging.basicConfig(
|
99
|
+
level=args.loglevel, format="[%(filename)s:%(lineno)s:%(levelname)s - %(funcName)30s() ] %(message)s"
|
100
|
+
)
|
101
|
+
|
102
|
+
##########################
|
103
|
+
# Terminal control and operational configuration constants
|
104
|
+
ERASE_LINE = "\x1b[2K" # ANSI escape sequence for clearing terminal line during progress display
|
105
|
+
SkipProfiles = ["default"] # Profile exclusion list for organizational Landing Zone discovery
|
106
|
+
|
107
|
+
# Configure AWS profile discovery strategy based on user input
|
108
|
+
if pProfiles is None:
|
109
|
+
# Default to single profile when no specific profiles are specified
|
110
|
+
print(f"You've provided no profile, so we'll use the default")
|
111
|
+
AllProfiles = ["default"]
|
112
|
+
elif "all" in pProfiles or "ALL" in pProfiles or "All" in pProfiles:
|
113
|
+
# Comprehensive multi-profile Landing Zone discovery across all available profiles
|
114
|
+
logging.info(
|
115
|
+
f"You specified 'all' as the profile, so we're going to check ALL of the profiles to find all of the management accounts, and list out all of their ALZ versions."
|
116
|
+
)
|
117
|
+
print(
|
118
|
+
"You've specified multiple profiles, so we've got to find them, determine which profiles represent Management Accounts, \n"
|
119
|
+
"and then parse through those. This will take a few moments."
|
120
|
+
)
|
121
|
+
# Discover all available profiles excluding specified skip profiles
|
122
|
+
AllProfiles = Inventory_Modules.get_profiles(fSkipProfiles=SkipProfiles, fprofiles=pProfiles)
|
123
|
+
else:
|
124
|
+
# Targeted profile-specific Landing Zone discovery based on user selection
|
125
|
+
AllProfiles = Inventory_Modules.get_profiles(fSkipProfiles=SkipProfiles, fprofiles=pProfiles)
|
126
|
+
|
127
|
+
# Execute comprehensive Landing Zone discovery across all configured profiles
|
128
|
+
ALZProfiles = [] # Initialize Landing Zone profile collection for discovered Management Accounts
|
129
|
+
|
130
|
+
for profile in AllProfiles:
|
131
|
+
# Display real-time progress during profile analysis with terminal line clearing
|
132
|
+
print(f"{ERASE_LINE}Checking profile: {profile}", end="\r")
|
133
|
+
|
134
|
+
try:
|
135
|
+
# Analyze current profile to determine if it represents an AWS Landing Zone Management Account
|
136
|
+
ALZMgmntAcct = Inventory_Modules.find_if_alz(profile)
|
137
|
+
|
138
|
+
if ALZMgmntAcct["ALZ"]:
|
139
|
+
# Extract account metadata for confirmed Landing Zone Management Accounts
|
140
|
+
accountnum = Inventory_Modules.find_account_number(profile)
|
141
|
+
ALZProfiles.append({"Profile": profile, "Acctnum": accountnum, "Region": ALZMgmntAcct["Region"]})
|
142
|
+
|
143
|
+
except ClientError as my_Error:
|
144
|
+
# Handle AWS API client errors with specific error type identification
|
145
|
+
if str(my_Error).find("UnrecognizedClientException") > 0:
|
146
|
+
logging.error("%s: Security Issue", profile)
|
147
|
+
elif str(my_Error).find("InvalidClientTokenId") > 0:
|
148
|
+
logging.error("%s: Security Token is bad - probably a bad entry in config", profile)
|
149
|
+
pass
|
150
|
+
|
151
|
+
except CredentialRetrievalError as my_Error:
|
152
|
+
# Handle credential retrieval errors for custom authentication processes
|
153
|
+
if str(my_Error).find("CredentialRetrievalError") > 0:
|
154
|
+
logging.error("%s: Some custom process isn't working", profile)
|
155
|
+
pass
|
156
|
+
|
157
|
+
except InvalidConfigError as my_Error:
|
158
|
+
# Handle configuration validation errors for profile-specific credential issues
|
159
|
+
if str(my_Error).find("InvalidConfigError") > 0:
|
160
|
+
logging.error(
|
161
|
+
"%s: profile is invalid. Probably due to a config profile based on a credential that doesn't work",
|
162
|
+
profile,
|
163
|
+
)
|
164
|
+
pass
|
165
|
+
|
166
|
+
# Clear progress display and initialize tabular output formatting for Landing Zone inventory
|
167
|
+
print(ERASE_LINE)
|
168
|
+
fmt = "%-20s %-13s %-15s %-35s %-21s" # Column formatting for structured Landing Zone data display
|
169
|
+
print(fmt % ("Profile", "Account", "Region", "ALZ Stack Name", "ALZ Version"))
|
170
|
+
print(fmt % ("-------", "-------", "------", "--------------", "-----------"))
|
171
|
+
|
172
|
+
# Execute comprehensive Landing Zone version analysis for each discovered Management Account
|
173
|
+
for item in ALZProfiles:
|
174
|
+
# Establish authenticated AWS session for CloudFormation stack analysis
|
175
|
+
aws_session = boto3.Session(profile_name=item["Profile"], region_name=item["Region"])
|
176
|
+
aws_client = aws_session.client("cloudformation")
|
177
|
+
|
178
|
+
# Retrieve comprehensive CloudFormation stack inventory for Landing Zone identification
|
179
|
+
stack_list = aws_client.describe_stacks()["Stacks"]
|
180
|
+
|
181
|
+
# Analyze each CloudFormation stack for AWS Landing Zone solution identification
|
182
|
+
for i in range(len(stack_list)):
|
183
|
+
logging.warning(f"Checking stack {stack_list[i]['StackName']} to see if it is the ALZ initiation stack")
|
184
|
+
|
185
|
+
# Identify Landing Zone stacks through solution ID (SO0044) in stack description
|
186
|
+
if "Description" in stack_list[i].keys() and stack_list[i]["Description"].find("SO0044") > 0:
|
187
|
+
# Extract Landing Zone version from CloudFormation stack outputs
|
188
|
+
for j in range(len(stack_list[i]["Outputs"])):
|
189
|
+
if stack_list[i]["Outputs"][j]["OutputKey"] == "LandingZoneSolutionVersion":
|
190
|
+
# Extract and display Landing Zone version information with formatted output
|
191
|
+
ALZVersion = stack_list[i]["Outputs"][j]["OutputValue"]
|
192
|
+
print(
|
193
|
+
fmt % (item["Profile"], item["Acctnum"], item["Region"], stack_list[i]["StackName"], ALZVersion)
|
194
|
+
)
|
195
|
+
|
196
|
+
# Display comprehensive operational summary with discovery metrics
|
197
|
+
print(ERASE_LINE)
|
198
|
+
print(f"Checked {len(AllProfiles)} accounts/ Orgs. Found {len(ALZProfiles)} ALZs")
|
199
|
+
print()
|
200
|
+
print("Thank you for using this script.")
|
201
|
+
print()
|