@staticmethod
    def _custom_policy(resource, expires=None, valid_after=None, ip_address=None):
        condition = {}
        if expires:
            condition["DateLessThan"] = {"AWS:EpochTime": expires}
        if valid_after:
            condition["DateGreaterThan"] = {"AWS:EpochTime": valid_after}
        if ip_address:
            if '/' not in ip_address:
                ip_address += "/32"
            condition["IpAddress"] = {"AWS:SourceIp": ip_address}
        policy = {"Statement": [{
                     "Resource": resource,
                     "Condition": condition}]}
        return json.dumps(policy, separators=(",", ":"))
Creates a custom policy string based on the supplied parameters.
dataset/ETHPy150Open darcyliu/storyboard/boto/cloudfront/distribution.py/Distribution._custom_policy