Cloud Multi Query is a library & CLI tool that allows you to run queries across multiple cloud accounts in parallel.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cmq-0.12.0.tar.gz.
File metadata
- Download URL: cmq-0.12.0.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8079314da533e7cd92fbff99a6915aa779f0087424f74bfd8b491fde71eda477
|
|
| MD5 |
8528c5f7db054b8b76e9652644e11679
|
|
| BLAKE2b-256 |
c38ecd086da905e070ed43b4ee7a091fcd1350cb42bf26a7bd91ed88fdf41518
|
Provenance
The following attestation bundles were made for cmq-0.12.0.tar.gz:
Publisher:
release.yml on ocadotechnology/cmq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cmq-0.12.0.tar.gz -
Subject digest:
8079314da533e7cd92fbff99a6915aa779f0087424f74bfd8b491fde71eda477 - Sigstore transparency entry: 1026748512
- Sigstore integration time:
-
Permalink:
ocadotechnology/cmq@62d23851bb47cbdaefa6068511bead2549382e8a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ocadotechnology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@62d23851bb47cbdaefa6068511bead2549382e8a -
Trigger Event:
push
-
Statement type:
File details
Details for the file cmq-0.12.0-py3-none-any.whl.
File metadata
- Download URL: cmq-0.12.0-py3-none-any.whl
- Upload date:
- Size: 36.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cf03ef51b552694d9ab5007f60abf1aed7294e9b337aeae5bb0ee031f4658b2
|
|
| MD5 |
c273a450dfc037b97a8bc750a84aa940
|
|
| BLAKE2b-256 |
b581ba1773ec68880f9712c5bc721e5d976932748929ea45e878855654a5d2e4
|
Provenance
The following attestation bundles were made for cmq-0.12.0-py3-none-any.whl:
Publisher:
release.yml on ocadotechnology/cmq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cmq-0.12.0-py3-none-any.whl -
Subject digest:
8cf03ef51b552694d9ab5007f60abf1aed7294e9b337aeae5bb0ee031f4658b2 - Sigstore transparency entry: 1026748610
- Sigstore integration time:
-
Permalink:
ocadotechnology/cmq@62d23851bb47cbdaefa6068511bead2549382e8a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ocadotechnology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@62d23851bb47cbdaefa6068511bead2549382e8a -
Trigger Event:
push
-
Statement type: