def clean_json(resource_json, resources_map):
    if isinstance(resource_json, dict):
        if 'Ref' in resource_json:
            # Parse resource reference
            resource = resources_map[resource_json['Ref']]
            if hasattr(resource, 'physical_resource_id'):
                return resource.physical_resource_id
            else:
                return resource

        if "Fn::FindInMap" in resource_json:
            map_name = resource_json["Fn::FindInMap"][0]
            map_path = resource_json["Fn::FindInMap"][1:]
            result = resources_map[map_name]
            for path in map_path:
                result = result[clean_json(path, resources_map)]
            return result

        if 'Fn::GetAtt' in resource_json:
            resource = resources_map.get(resource_json['Fn::GetAtt'][0])
            if resource is None:
                return resource_json
            try:
                return resource.get_cfn_attribute(resource_json['Fn::GetAtt'][1])
            except NotImplementedError as n:
                logger.warning(n.message.format(resource_json['Fn::GetAtt'][0]))
            except UnformattedGetAttTemplateException:
                raise BotoServerError(
                    UnformattedGetAttTemplateException.status_code,
                    'Bad Request',
                    UnformattedGetAttTemplateException.description.format(
                        resource_json['Fn::GetAtt'][0], resource_json['Fn::GetAtt'][1]))

        if 'Fn::If' in resource_json:
            condition_name, true_value, false_value = resource_json['Fn::If']
            if resources_map[condition_name]:
                return clean_json(true_value, resources_map)
            else:
                return clean_json(false_value, resources_map)

        if 'Fn::Join' in resource_json:
            join_list = []
            for val in resource_json['Fn::Join'][1]:
                cleaned_val = clean_json(val, resources_map)
                join_list.append('{0}'.format(cleaned_val) if cleaned_val else '{0}'.format(val))
            return resource_json['Fn::Join'][0].join(join_list)

        cleaned_json = {}
        for key, value in resource_json.items():
            cleaned_json[key] = clean_json(value, resources_map)
        return cleaned_json
    elif isinstance(resource_json, list):
        return [clean_json(val, resources_map) for val in resource_json]
    else:
        return resource_json
Text properties may not be used in query filters.
dataset/ETHPy150Open spulec/moto/moto/cloudformation/parsing.py/clean_json--crossover with--dataset/ETHPy150Open jahlborn/appengine-rest-server/src/main/python/rest/__init__.py/TextHandler.can_query