diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 51ef2a124..c885dac9e 100755 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -1835,6 +1835,8 @@ class Volume(TaggedEC2Resource): return self.id elif filter_name == 'encrypted': return str(self.encrypted).lower() + elif filter_name == 'availability-zone': + return self.zone.name else: return super(Volume, self).get_filter_value( filter_name, 'DescribeVolumes') diff --git a/tests/test_ec2/test_elastic_block_store.py b/tests/test_ec2/test_elastic_block_store.py index fc0677cfe..95d410052 100644 --- a/tests/test_ec2/test_elastic_block_store.py +++ b/tests/test_ec2/test_elastic_block_store.py @@ -186,6 +186,11 @@ def test_volume_filters(): {volume1.id, volume3.id, volume4.id} ) + volumes_by_availability_zone = conn.get_all_volumes(filters={'availability-zone': 'us-east-1b'}) + set([vol.id for vol in volumes_by_availability_zone if vol.id in volume_ids]).should.equal( + {volume2.id} + ) + @mock_ec2_deprecated def test_volume_attach_and_detach():