def METHOD_NAME(self, region, url_to_sign):
    credentials = self._session.get_credentials()
    signer = SigV4Auth(credentials, 'codecommit', region)
    request = AWSRequest()
    request.url = url_to_sign
    request.method = 'GIT'
    now = datetime.datetime.utcnow()
    request.context['timestamp'] = now.strftime('%Y%m%dT%H%M%S')
    split = urlsplit(request.url)
    # we don't want to include the port number in the signature
    hostname = split.netloc.split(':')[0]
    canonical_request = '{0}\n{1}\n\nhost:{2}\n\nhost\n'.format(
        request.method,
        split.path,
        hostname)
    logger.debug("Calculating signature using v4 auth.")
    logger.debug('CanonicalRequest:\n%s', canonical_request)
    string_to_sign = signer.string_to_sign(request, canonical_request)
    logger.debug('StringToSign:\n%s', string_to_sign)
    signature = signer.signature(string_to_sign, request)
    logger.debug('Signature:\n%s', signature)
    return '{0}Z{1}'.format(request.context['timestamp'], signature)