Starting a Python-oriented Serverless-dot-com Project
In the past few months, I’ve created about a half-dozen projects using «serverless» infrastructure on Amazon Web Services (AWS).
(And I’m about to start another one.)
Over the course of these projects, I’ve refined my development environment into something that I think is useful to share, so read on for how to make Python, Node, and Serverless.com work together and work independently from your other projects.
About «Serverless»
«Serverless» is both a term for a kind of computing environment and the name of a framework that helps manage such environments.
As a computing environment, «serverless» abstracts away the needs to manage the servers and underlying operating systems from the task of writing and running code.
If you assume that a fully-patched server at the required capacity is ready and waiting to run your code, then a serverless environment allows the developer to focus on just running the code.
Someone else will deal with the other parts.
AWS’
Lambda
is probably the best known, but other major cloud computing environments (
Microsoft Azure
,
Google Cloud Services
,
Cloudflare Workers
) and datacenter tools (
Apache OpenWhisk
,
Kubeless
) have the same thing.
»
serverless.com
» is also the name of a specific framework that helps developers manage serverless environments.
It takes care of the tasks of bundling up code, setting up the appropriate triggers (web APIs, message queues, etc.), managing versions, and similar tasks.
To make matters even more confusing, «Serverless.com» is also a service for managing workloads in serverless environments…so hopefully you can see that talking about «serverless» quickly gets one to «what ‘serverless’ are you talking about?»
As far as understanding serverless-the-framework, I recommend skipping the homepage and going right to the
framework documentation
.
Building Up the Environment
There is one globally-installed prerequisite that I use:
pipenv
.
Pipenv creates isolated Python environments…the python executable and installed modules for the project are separated from those of the underlying operating system.
There are many isolated Python environment tools—
pipenv
,
virtualenv
,
poetry
—but I’ve used pipenv for a long time and it has the advantage of working with Eugene Kalinin’s
nodeenv
project: a Node isolation tool that integrates with pipenv.
In other words, in one directory I’m getting both Python isolation and Node isolation.
The numbered steps below are the sequence of commands to set this up. If you want to see what an empty shell looks like—along with some strong opinions about how I like to set up Serverless for myself—check out this GitHub repository:
dltj/serverless-template
.
mkdir serverless_project && cd serverless_project
— create an empty directory and change into it
PIPENV_VENV_IN_PROJECT=1 pipenv install
— create an isolated installation of Python in this environment
[note 1]
pipenv install –dev nodee…
Descubre más desde Hoy En Perspectiva
Suscríbete y recibe las últimas entradas en tu correo electrónico.