'Rollback the lambda function code \'versions_back\' number of revisions.
Returns the Function ARN.'

def rollback_lambda_function_version(self, function_name, versions_back=1, publish=True):

    response = self.lambda_client.list_versions_by_function(FunctionName=function_name)
    if (len(response['Versions']) < (versions_back + 1)):
        print('We    do    not    have    {}    revisions.    Aborting'.format(str(versions_back)))
        return False
    revisions = [int(revision['Version']) for revision in response['Versions'] if (revision['Version'] != '$LATEST')]
    revisions.sort(reverse=True)
    response = self.lambda_client.get_function(FunctionName='function:{}:{}'.format(function_name, revisions[versions_back]))
    response = requests.get(response['Code']['Location'])
    if (response.status_code != 200):
        print('Failed    to    get    version    {}    of    {}    code'.format(versions_back, function_name))
        return False
    response = self.lambda_client.update_function_code(FunctionName=function_name, ZipFile=response.content, Publish=publish)
    return response['FunctionArn']
