Python Serverless Framework — AWS Chalice for Lambda

Chalice is a framework for writing serverless apps in Python that allows you to quickly create and deploy applications that use AWS Lambda

Michael Whittle
Level Up Coding
Published in
6 min readNov 1, 2020

--

I assume you are already familiar with AWS Lambda and API Gateway and how they work. If not, I recommend reading one of my most popular articles, “React.js API calls to AWS Lambda, API Gateway and dealing with CORS’. At a high level it allows you to deploy applications “serverless”. This actually may sound misleading as there are servers involved but it is “serverless” in the sense you don’t need to worry about them. You just pay for execution time of your application function(s). AWS Lambda natively supports Java, Go, PowerShell, Node.js, C#, Python, and Ruby code, and provides a Runtime API which allows you to use any additional programming languages to author your functions. I personally have not encountered anyone using anything other than Node.js or Python for their functions. My previous articles have all used Node.js as examples but I thought it would be worth adding a Python example as well. If you are using Python for your functions there is a really nice Python serverless framework called, “AWS Chalice”. If you are familiar with the Flask framework for Python it is based on that.

Let’s get started…

AWS API

You will need to install the AWS CLI and in order to do that the first step you need to sort out a few steps in IAM which will require a root or administrator account.

In IAM, click on “Groups”, then “Create New Group”. Add a new group (if it doesn’t already exist) called “Administrators” and attach a policy called “AdministratorAccess”. Add your user to the “Administrators” group by opening the group and clicking on “Add Users to Group” under the “Users” tab.

In IAM, click on “Users”, open your user account (which should now be part of the “Administrators” group, and click on the “Security credentials” tab. If you have an access key setup and remember the details then great. If you don’t have an access key or have misplaced the details, just create a new one. Make sure you make note of the “Access key ID” and “Secret access key”. In my case I deleted…

--

--

Solution Architect — CCIE R&S #24223 | Full-Stack / Blockchain / Web3 Developer | Security Specialist | PyCryptoBot Creator