From d3dcb8d3b5c221a86b64f2a33c4019694fb7a599 Mon Sep 17 00:00:00 2001 From: Kieran Doonan Date: Tue, 5 Jul 2016 11:28:35 +0100 Subject: [PATCH] tag_filter_matches now uses regex for key/value matches --- moto/ec2/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/moto/ec2/utils.py b/moto/ec2/utils.py index e07367081..d8bc6528a 100644 --- a/moto/ec2/utils.py +++ b/moto/ec2/utils.py @@ -348,8 +348,10 @@ def tag_filter_matches(obj, filter_name, filter_values): tag_values = get_obj_tag_values(obj) return len(set(filter_values).intersection(tag_values)) > 0 else: - tag_value = get_obj_tag(obj, filter_name) - return tag_value in filter_values + import re + tag_value = get_obj_tag(obj, filter_name) or '' + regex_filters = [re.compile(simple_aws_filter_to_re(f)) for f in filter_values] + return any(regex.match(tag_value) for regex in regex_filters) filter_dict_attribute_mapping = {