boto3aws-ebs

describe_snapshots filter in boto3 not working on "description" field


I am trying to filter snapshots based on description using boto3, but the description filter doesn't seem to work. See below:

>>> ec2.describe_snapshots(Filters=[{'Name':'snapshot-id','Values':['snap-yyyy']}],MaxResults=10,OwnerIds=['xxxxx'])['Snapshots']
[{u'Description': 'snap-yyyy blah blah', u'VolumeSize': 100, u'VolumeId': 'vol-ffffffff', u'State': 'completed', u'StartTime': datetime.datetime(2018, 6, 12, 9, 59, 16, tzinfo=tzutc()), u'Progress': '100%', u'OwnerId': 'xxxxx', u'SnapshotId': 'snap-yyyy'}]

If I then take the snapshot description and use that to search, I get nothing back:

>>> ec2.describe_snapshots(Filters=[{'Name':'description','Values':['snap-yyyy blah blah']}],MaxResults=10,OwnerIds=['xxxxx'])['Snapshots']
[]

OwnerId and snapshotId has been redacted, but VolumeId is actually vol-fffffff due to the snapshot being a copy of a snapshot from a different region.

Is there a reason that a description filter doesn't match? According to the docs, description is a valid field to filter by - https://boto3.readthedocs.io/en/latest/reference/services/ec2.html#EC2.Client.describe_snapshots


Solution

  • Call describe_snapshots() without passing MaxResults and OwnerIds. Call it with just the filter with description