amazon web services - How to filter Tag keys using aws boto3 starting with 'aws:' in ec2.describe_tags? -
we using following python code tags associated ebs volume , transfer them snapshots associated ebs volume. , want exclude aws: reserved tags output can apply them directly is.
import boto3 ec2 = boto3.client('ec2') volume_tags = ec2.describe_tags(filters=[{'name': 'resource-id', 'values': ['volume-id',],},],) tag_snapshot = ec2.create_tags(resources=[snapshot-id],tags=volume_tags)
you can use 'jq' program aws cli filter json results below
aws ec2 describe-tags | jq '.tags[] | select(contains({key: "aws:"}) | not)'
possibly use subprocess execute above command python
unfortunately i'm unable try same using python bindings jq.
jq or pyjq python bindings have installation issues using pip me
wiki
Comments
Post a Comment