From 4a99dcddb26a012a1a6a8b71fd242bc82edd1b33 Mon Sep 17 00:00:00 2001 From: Jeffery Smith Date: Sat, 25 May 2019 05:34:59 -0400 Subject: [PATCH] Issue #2141 Adding owner-id to the filter for Snapshot (#2142) * Adding owner-id to the filter for Snapshot --- moto/ec2/models.py | 2 ++ tests/test_ec2/test_elastic_block_store.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 685558c35..d57b9f01b 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -1881,6 +1881,8 @@ class Snapshot(TaggedEC2Resource): return str(self.encrypted).lower() elif filter_name == 'status': return self.status + elif filter_name == 'owner-id': + return self.owner_id else: return super(Snapshot, self).get_filter_value( filter_name, 'DescribeSnapshots') diff --git a/tests/test_ec2/test_elastic_block_store.py b/tests/test_ec2/test_elastic_block_store.py index 8f4a00b13..728be5d1f 100644 --- a/tests/test_ec2/test_elastic_block_store.py +++ b/tests/test_ec2/test_elastic_block_store.py @@ -394,6 +394,11 @@ def test_snapshot_filters(): set([snap.id for snap in snapshots_by_encrypted] ).should.equal({snapshot3.id}) + snapshots_by_owner_id = conn.get_all_snapshots( + filters={'owner-id': '123456789012'}) + set([snap.id for snap in snapshots_by_owner_id] + ).should.equal({snapshot1.id, snapshot2.id, snapshot3.id}) + @mock_ec2_deprecated def test_snapshot_attribute():