Getting started
For this tutorial, I’m going to use the Serverless framework ( serverless.com), which allows you to deploy to AWS, Google’s Cloud, MS Azure and IBM. All the examples here will be on AWS, but you should check out whichever platform matches your needs. Serverless currently supports several runtimes including Node, Java Maven, Gradle, Scala, and C#. The community is very active so visit them on their Slack channel to see if your runtime will be supported.
The big advantage of using the Serverless framework is all the time it saves you getting basic things set up. Getting an API endpoint is just about as easy in AWS, but it’s trivially easy with Serverless, as we’ll see.
To get started, set up an AWS account if you don’t already have one. (The cost of what we’re going to build is a few pennies, but make sure you delete everything you create when you’ve finished.) Then install the Serverless framework, create a new project using Python 3 as the runtime and see
Now modify serverless.yml so that we use Python 3 and the profile we just configured: provider: name: aws runtime: python3.6 profile: tutorial-profile region: us-east-1
Open up handler.py and personalise the ‘message’ parameter: “message": “This is a tiny function...”,
Now let’s deploy and invoke the function: serverless deploy -v serverless invoke -f hello
The Serverless framework just created a CloudFormation configuration to create all the resources required for your tiny function to run in the AWS cloud. It then zips up and uploads your code. This is simultaneously amazing and hugely
underwhelming, so how about we build something a bit more impressive?