From 1ff24981eea9a4241e557ca766c0885ed283a1bf Mon Sep 17 00:00:00 2001 From: gigimon Date: Wed, 3 Feb 2016 18:05:25 +0300 Subject: [PATCH] * add filter by instance-id for describeAdresses --- moto/ec2/responses/elastic_ip_addresses.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/moto/ec2/responses/elastic_ip_addresses.py b/moto/ec2/responses/elastic_ip_addresses.py index 79d586131..387a7ff4d 100644 --- a/moto/ec2/responses/elastic_ip_addresses.py +++ b/moto/ec2/responses/elastic_ip_addresses.py @@ -44,7 +44,12 @@ class ElasticIPAddresses(BaseResponse): template = self.response_template(DESCRIBE_ADDRESS_RESPONSE) if "Filter.1.Name" in self.querystring: - raise NotImplementedError("Filtering not supported in describe_address.") + filter_by = sequence_from_querystring("Filter.1.Name", self.querystring)[0] + filter_value = sequence_from_querystring("Filter.1.Value", self.querystring) + if filter_by == 'instance-id': + addresses = filter(lambda x: x.instance.id == filter_value[0], self.ec2_backend.describe_addresses()) + else: + raise NotImplementedError("Filtering not supported in describe_address.") elif "PublicIp.1" in self.querystring: public_ips = sequence_from_querystring("PublicIp", self.querystring) addresses = self.ec2_backend.address_by_ip(public_ips)