'Creates a custom policy string based on the supplied parameters.'

@staticmethod
def _custom_policy(resource, expires=None, valid_after=None, ip_address=None):

    condition = {}
    if (not expires):
        expires = (int(time.time()) + 86400)
    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=(',', ':'))
