A mapping run, step by step¶
InventoryMapper(config, tagging_sweep=None).map_inventory():
- Copy the configuration.
config.model_copy(deep=True); discovery may rewrite the AWS account list, role and regions, and the caller's config object is never mutated. - AWS Organization discovery (
aws.organization.enabled). Runs in a worker thread:- builds a session in
home_regionor the primary region with the base credentials; discover_organization()(6);target_accounts()with the OU / exclusion / management / suspended filters, intersected withaws.accountswhen that is also set;- sets
cfg.aws.accountsto the selection andcfg.aws.role_nametoorganization.role_name, elseaws.role_name, elseAWSControlTowerExecution; - with
use_governed_regionsandregions: [all], replaces the regions with the Control Tower governed regions. Failure is recorded as coverage (organizations: FAILED) and the run continues with the caller's account only.
- builds a session in
- Other hierarchies. Azure management groups and policy (
azure.map_management_groups), GCP organization / folders / policies (gcp.organization_idandgcp.map_hierarchy). - Collection.
MultiAccountCollector(cfg, collector_overrides=…)with the deep collectors:- AWS: one task per account × region, limited by
concurrency_limit. The account-wide services run only in the primary region (us-east-1when collected, else the first region), passed asis_primary_regionto collectors that declaresupports_region_scoping. The caller's own account is collected with the base credentials, because member roles such asAWSControlTowerExecutiondo not exist in the management account. A failed role assumption recordssts_assume_roleand skips that account and region. - Azure: every configured subscription, or every Enabled subscription
(
azure.all_subscriptions), one credential for the run. Resource Graph returns all locations, so there is no per-region loop. - GCP: one Cloud Asset Inventory listing at
organizations/<id>(withproject_idsas a filter) whencollection_scopeallows it, else one per project. - Each unit runs
collect()thencollect_edges()and records coverage. The deep collector options fromInventoryConfigare bound through a small subclass (_ConfiguredAWS) that keeps the(session, region, account_id)constructor the orchestrator expects.
- AWS: one task per account × region, limited by
- Merge discovery assets.
topology.to_assets()(withmap_structure) and the Azure / GCP hierarchy assets are prepended to the collected assets. - Link (
_link):deduplicate(): one asset perarn, relations and aliases merged, edges re-pointed.merge_gcp_principals()(GCP only): folds per-project service-account placeholders into the real service accounts.RelationshipLinker(assets),seed_existing(edges),link(include_generic=link_references).- External account placeholders appended to the assets.
add_account_hierarchy()(withinventory.account_hierarchy).
- Result.
InventoryResultwith the discovery coverage first, the resolved regions,topology.to_dict()and the linker's unresolved references.
CloudGEngine.map_inventory() wraps this and additionally exports the files (and the findings
overlay) when output_dir is given. cloudg map adds the console output and --findings.