Skip to main content

CMQ

Cloud Multi Query (CMQ) is a Python library & CLI tool that allows you to run the same query across multiple cloud accounts in parallel, making it easy to gather insights and manage multi-account environments efficiently.

So far, CMQ only supports AWS cloud accounts. However, the plugable structure of CMQ allows for the creation of new session and resource types to include other cloud providers.

Installation

pip install cmq

Basic usage

CMQ works using profiles defined in your local machine (AWS CLI configuration). It's expected that every profile defines the access to an account/region.

Let's start listing the configured profiles:

cmq 'profile().list()'
[
   {
    "name": "account_a",
    "region": "us-east-1"
  },
  {
    "name": "account_b",
    "region": "eu-west-1"
  }
]

We can list resources for these accounts. CMQ will execute the queries in parallel. For example, lets list RDS resources:

cmq 'profile().rds().list()'
[
 {
    "DBInstanceIdentifier": "account-a-users",
    "DBInstanceClass": "db.m6g.large",
    "Engine": "postgres",
    ...
 },
 {
    "DBInstanceIdentifier": "account-b-users",
    "DBInstanceClass": "db.m6g.large",
    "Engine": "postgres",
    ...
 },
 ...
]

We can also use cmq as a Python library. This is more convenient when you need to process the results:

>>> from cmq.aws.session.profile import profile
>>> profile().sqs().list()
[
 {"resource": "https://sqs.us-east-1.amazonaws.com/123456789012/account-a-products"},
 {"resource": "https://sqs.us-east-1.amazonaws.com/123456789012/account-a-orders"},
 {"resource": "https://sqs.eu-west-1.amazonaws.com/210987654321/account-b-products"},
 {"resource": "https://sqs.eu-west-1.amazonaws.com/210987654321/account-b-orders"}
]

Enable verbose output

We can export the environment variable CMQ_VERBOSE_OUTPUT=true or use the option verbose in the CLI to output the progress of the query. This is particular useful when you have many accounts to process:

cmq --verbose 'profile().elasticache().list()'
 100.00% :::::::::::::::::::::::::::::::::::::::: |        1 /        1 |:  account-dev     elasticache
 100.00% :::::::::::::::::::::::::::::::::::::::: |        1 /        1 |:  account-test    elasticache
 100.00% :::::::::::::::::::::::::::::::::::::::: |        1 /        1 |:  account-prd1    elasticache
 100.00% :::::::::::::::::::::::::::::::::::::::: |        1 /        1 |:  account-prd2    elasticache
 100.00% :::::::::::::::::::::::::::::::::::::::: |        1 /        1 |:  account-prd3    elasticache
[
    ... resource list ...
]

Docs

Examples

List RDS resources in one profile with name account_a

cmq 'profile(name="account_a").rds().list()'

List SNS topics for all profiles, but returning a dictionary where the key is the name of the profile:

cmq 'profile().sns().dict()'
{
    "account_a": [
        ... topics from account a ...
    ],
     "account_b": [
        ... topics from account b ...
    ],
}

List all roles for all accounts, but return only the RoleName field:

cmq 'profile().role().attr("RoleName").list()'

List DynamoDB tables, but limit the results to 10 tables:

cmq 'profile().dynamodb().limit(10).list()'

CMQ uses boto3 to list/describe resources. You can also use the parameters of the boto3 functions to filter resources in the request. For example, this will list all SQS queues with prefix order in all accounts:

cmq 'profile().sqs(QueueNamePrefix="order").list()'

We can also filter resources in the response. CMQ is built with a set of quick filters that you can use with any resource type. All the filters have the same structure: __filter__(key, value)

For example, the following query list Lambda functions running with python3.10 in all accounts:

cmq 'profile().function().eq("Runtime", "python3.10").list()'

These are the supported quick filters:

  • eq
  • ne
  • in_
  • contains
  • not_contains
  • starts_with
  • ends_with
  • gt
  • lt

Supported resources

AWS

  • address
  • alarm
  • cloudformation
  • cloudtrail
  • dynamodb
  • ec2
  • elasticache_parameter_group
  • elasticache_replication_group
  • elasticache_subnet_group
  • elasticache
  • function
  • kinesis
  • kms_alias
  • kms
  • log_event
  • log_stream
  • log
  • metric
  • rds_parameter_group
  • rds
  • resource_explorer
  • resource_group
  • role
  • s3_object
  • s3
  • sns
  • sqs
  • user_key
  • user

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmq-0.15.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmq-0.15.0-py3-none-any.whl (37.6 kB view details)

Uploaded Python 3

File details

Details for the file cmq-0.15.0.tar.gz.

File metadata

  • Download URL: cmq-0.15.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cmq-0.15.0.tar.gz
Algorithm Hash digest
SHA256 c3572a83ceb1727b84fa00156b86439ba553119f4cd976b46fe2bf1cce5966af
MD5 d98b062f405535cc44a80ee27e2e090c
BLAKE2b-256 407dc31a6ea485bec89de9cc9a9c8f7cfe2fd59c1d1776956e469b6095383af9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cmq-0.15.0.tar.gz:

Publisher: release.yml on ocadotechnology/cmq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cmq-0.15.0-py3-none-any.whl.

File metadata

  • Download URL: cmq-0.15.0-py3-none-any.whl
  • Upload date:
  • Size: 37.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cmq-0.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b28b0cbdb0094f391bd6384322c4c5872d81776f6d40f86ab5047b577ead98c
MD5 b4548c976b4b728704fe2b22359edbe5
BLAKE2b-256 18c76ab386db5fd6646cb3c6f8588c078fa8892a668a49b5f454cbd0858c9a8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cmq-0.15.0-py3-none-any.whl:

Publisher: release.yml on ocadotechnology/cmq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.15.0 This release

2 files

0.14.0

2 files

0.13.0

2 files

0.12.0

2 files

0.11.1

2 files

0.11.0

2 files

0.10.1

2 files

0.10.0

2 files

0.9.1

2 files

0.9.0

2 files

0.8.1

2 files

0.8.0

2 files

0.7.1

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.3

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page