jmespath custom functions for filtering AWS resources by tag
Project description
aws-jmespath-utils
Installation
pip3 install aws_jmespath_utils
Examples
Check out the example code:
Usage
Find resources with 'Name' tag set
jmespath.search( # it's important that your expression array must be inside `` backticks
'[] | filter_tags(`["Name=*"]`, @)', data_list, options=jmespath_options
)
Find tag values starting with 123
jmespath.search( # it's important that your expression array must be inside `` backticks
'[].filter_tags(`["=123*"]`, @)', data_list, options=jmespath_options
)
Find Many tag values
jmespath.search( # it's important that your expression array must be inside `` backticks
'[].filter_tags(`["=123*", "=jmespath*"]`, @)', data_list, options=jmespath_options
)
Exclude Tags
jmespath.search( # it's important that your expression array must be inside `` backticks
'[].exclude_tags(`["map-migrated=*"]`, @)', data_list, options=jmespath_options
)
Setting log levels
# set log level as you wish
export AWS_JMESPATH_UTILS_LOG_LEVEL="DEBUG"
export AWS_JMESPATH_UTILS_LOG_LEVEL="INFO" # default
Complete Usage Example
import jmespath
from aws_jmespath_utils import jmespath_options
import json
data_list = [
{"a": "a", "Tags": [{"Key": "Name", "Value": "jmespath-utils"}, ]},
{"b": "b", "Tags": [{"Key": "Nam", "Value": "jmespath-utils-nam"}]},
{"c": "c", "Tags": [{"Key": "map-migrated", "Value": "234"}]}
]
print(
json.dumps(
jmespath.search('[] | filter_tags(`["Name=*"]`, @)', data_list, options=jmespath_options),
indent=2
)
)
print(
json.dumps(
jmespath.search('[] | exclude_tags(`["Nam*="]`, @)', data_list, options=jmespath_options),
indent=2
)
)
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
File details
Details for the file aws_jmespath_utils-0.2.1.tar.gz
.
File metadata
- Download URL: aws_jmespath_utils-0.2.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.12 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fdbf5885606debb49cb909c25f5abe03382ccd7878c338917693178683b435e |
|
MD5 | c9d4298e6cd9ea21d0bc37b48cc2a16c |
|
BLAKE2b-256 | 91aa6f34babdd06e4c96b7115fad9529775500b95f83f81ece21d77567825538 |
File details
Details for the file aws_jmespath_utils-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: aws_jmespath_utils-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.12 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06a770d4e04aa4a539009d7bb3ea2b27633d379deec801d653759b69e5e649f3 |
|
MD5 | 336132354359d7468f0a22a023c3c591 |
|
BLAKE2b-256 | 98a77f018b8c6d24c08b3e414f8f51a3853eca9f2e6d7db903b316f2ad2b066b |