Build and deploy a Python based serverless REST API in no time. AWS Chalice is a serverless framework that allows you to build serverless applications using Python, and deploy them on AWS using Amazon API Gateway and AWS Lambda.

I recently came across AWS Chalice and was fascinated by the simplicity and usability it offers.

AWS Chalice is a serverless framework that allows you to build serverless applications using Python, and deploy them on AWS using Amazon API Gateway and AWS Lambda.

I decided to play around with it and was actually able to create and deploy a sample REST API on AWS within a few minutes.

In this article, I will walk you through the steps required to build and deploy a serverless application that gets the latest news from Google News using Chalice.

Prerequisites

This tutorial requires an AWS account. If you don’t have one already, go ahead and create one. Our application is going to use only the free-tier resources, so cost shouldn’t be an issue.

You also need to configure security and create users and roles for your access.

How to Configure AWS Credentials

Chalice uses the AWS Command Line Interface (CLI) behind the scenes to deploy the project. If you haven’t used AWS’s CLI before to work with AWS resources, you can install it by following the guidelines here.

Once installed, you need to configure your AWS CLI to use the credentials from your AWS account.

How to Install Chalice

Next, you need to install Chalice. We will be using Python 3 in this tutorial, but you can use any version of Python supported by AWS Lambda.

Verify Python Installation

Install Chalice

Verify Chalice Installation

How to Create a Project

Next, run the chalice new-project command to create a new project.

This will create a daily-news folder in your current directory. You can see that Chalice has created several files in this folder. We’ll be working with the app.py and requirements.txt files only in this article.

Let’s take a look at the contents of app.py file:

from chalice import Chalice

app = Chalice(app_name='daily-news')

@app.route('/')
def index():
    return {'hello': 'world'}

#serverless #aws #api #python #developer

How to Build a Serverless Application Using AWS Chalice
4.65 GEEK