Skip to content

5.1 Composition

The AWS deep collector · From docs/INVENTORY_INTERNALS.md on GitHub

AWSDeepInventoryCollector is a stack of mixins on top of AsyncAWSCollector:

class AWSDeepInventoryCollector(
    GovernanceCollectorsMixin,
    NetworkExtCollectorsMixin,
    ApplicationCollectorsMixin,
    DataMLCollectorsMixin,
    IdentityCollectorsMixin,
    ContainerCollectorsMixin,
    ServerlessCollectorsMixin,
    SecurityCollectorsMixin,
    PlatformCollectorsMixin,
    CloudControlCollectorsMixin,
    AsyncAWSCollector,
): ...

Rules that follow from the MRO:

  • Mixins come before AsyncAWSCollector. A mixin's _collect_s3 overrides the base collector's. AWSServiceMixin declares _region, _account_id and _aio_config as annotations only; it must never define stubs for AsyncAWSCollector methods, or it would shadow them.
  • Method names are global across all mixins. Two mixins defining the same helper silently shadow each other (the one earlier in the MRO wins). Prefix package-private helpers (the data/ML package uses _dm_role_ref for that reason) and check with grep -rn "def <name>" cloudg/inventory/aws_services before adding one.
  • Package mixins are themselves compositions (ApplicationCollectorsMixin combines twelve per-area mixins), so each package keeps one place in the MRO.

Constructor: AWSDeepInventoryCollector(session, region="us-east-1", account_id=None, tagging_sweep=True, **options). tagging_sweep stays the fourth positional parameter for 0.5.0 compatibility; every other option is keyword-only and validated by the DeepInventoryOptions dataclass, so an unknown option name raises TypeError.

Option Default Effect
tagging_sweep True Run the Tagging API sweep.
is_primary_region True Collect account-wide tasks here.
services all Families / task names to include.
exclude_services none Families / task names to skip (wins over services).
kubernetes True Map in-cluster objects of EKS clusters. Also requires that kubernetes is not excluded and that all, kubernetes, containers or eks is selected.
kubernetes_timeout 10 Kubernetes API timeout, seconds.
iam_resource_edges True Link principals to resources their identity policies name.
max_images_per_repository 20 ECR images sampled per repository (for tags, scan findings).
stack_resources True Link CloudFormation stacks to their resources.
cloud_control True Run the Cloud Control sweep.
cloud_control_types all Only these CloudFormation types or prefixes.
cloud_control_exclude none Skip these types or prefixes.
cloud_control_concurrency 6 Types listed in parallel per region.