def build_plural_mappings(special_mappings, resource_map):
    """Create plural to singular mapping for all resources.

    Allows for special mappings to be provided, like policies -> policy.
    Otherwise, will strip off the last character for normal mappings, like
    routers -> router.
    """
    plural_mappings = {}
    for plural in resource_map:
        singular = special_mappings.get(plural)
        if not singular:
            if plural.endswith('ies'):
                singular = '%sy' % plural[:-3]
            else:
                singular = plural[:-1]
        plural_mappings[plural] = singular
    return plural_mappings
