As we discussed in my previous post about Introduction to Serverless, today we are going to build a very simple Todo application using Python, Serverless framework and AWS Lambda.

Today’s content is focused on development and deployment of the application. So the topic we are going to cover is:

without further ado, let’s get started. Ready to get your hands dirty?

Open Your pc, Open your code editor and wear your superhero suit to start the journey of building a serverless application with me.


  • Python installed on your machine and know basic of python.
  • AWS account and AWS CLI installed on your machine.
  • Serverless framework installed on your machine.
  • Git Installed and [Github] account for version controlling and remote repository. (Optional)

I know most of your didn’t have AWS account. Our current situation in Ethiopia it is not easy to get an AWS account. For that reason, I am going to connect my Master card to your aws account to use the AWS Free tier account. The catch is i have some question the first few people who answer correctly will get the aws account.

For the Contest please refer to this here

Pre-requisites in Activity

Creating AWS IAM

I am not going to teach you how to use your aws account in this blog but please follow the best practice and create IAM account even for your usage. Please see this Blog by AWS

So now we are going to create AWS IAM user for our deployment later usage. Here are the step your should follow:

  1. Go to IAM by searching in aws search panel AWS-Search

  2. Click Users in the left navigation bar and Click Add Users

  3. Give a name of your choice in User name field and select Access key - Programmatic access under the Select AWS access type

  4. After you click next, it let’s you choose permission for the user. For now we are going to give Full Admin Access Yet in your real world application you have to make sure you give the right amount of permission for your user. Select Create Group

  5. Give the name of your choice and select AdministratorAccess under Policy name and click Create

  6. After you created the Group select the group for the our new user. After that click Next and skip the tag creation for now and Click Review. After all this Review everything you set like the name and other stuff anc click Create User

  7. Make sure not to close the window before you grab the access key and Secret key. Put them in a safe place we are going to use them in a bit.

That is all for creating user. I promise you it is a very easy process to create this if you are scared because we have 7 step. I wanna make sure to led you at every step.

The next thing we are going to do is setting up our Serverless framework. It is also a very easy process.

  1. Install NodeJs(LTS is better) for the serverless framework is build by NodeJs.
  2. Install the serverless framework by using the below code
npm install -g serverless
  1. configure AWS. Just paste your AWS Access key and secret key below
serverless config credentials --provider aws --key YOUR_ACCESS_KEY --secret YOUR_SECRET_KEY


sls config credentials --provider aws --key YOUR_ACCESS_KEY --secret YOUR_SECRET_KEY

Serverless can be access in your command line by typing serverless or sls

  1. There wont be 4th step 😜

Create a Serverless project

If you are going to use Git and Github. Go create new repo and and clone it in your local machine. After that go to that directory and open terminal.

Now Open terminal and go to the directory you wanna work with. I suggest you have folder like project -> Serverless

Now let’s initialize our project.


Enter and choose AWS - Python - HTTP API Name for the project Todo or anything you want but make sure to change it for the rest of the blog.

Let’s open our code editor and start looking at the project.

You will find a new folder in the current directory which is name same as the project name you given in the above process while creating project.

│   .gitignore
|   serverless.yml

No go to your serverless.yml and paste the below code. I have put comment on it.

You can skip the part that says Optional but I recommend to do it.

Now we are done with setting up the project. Let’s move to DynamoDB stuff.

Create dynamodb table

DynamoDB is aws fully managed NoSQL database. It is very simple and easy to use, Yet powerful to scale your database without worrying about sharding or any advanced stuff in database. If you want to read more please here.

Now let’s edit our DynamoDB in our serverless.yml file and paste the below code.

Notice: #new comment to indicate the added line of code.

Here what is happening is we are defining our Database Schema to be created when we deployed.

You might ask me so will it be create whenever we deployed ? The answer is No. Serverless will check the dynamo table using the name so if the name exists it won’t create it. Instead it will grab it’s ARN and use it to point to the DB. Another question pop up right?

What is ARN ? we wont keep up with these question because you might be educated about the cloud by the LEGENDARY ME 😝(like i know ntg). So ARN is Amazon Resource Names. Easy right. it is identifier of the resource. Like your name or your phone number identifies you.

We only define todoId in our dynamo if you notice it because we know have to give dynamodb the key or as we knew before same like primary key.

Do you know in SQL primary key will be indexed by default which makes it very fast if you search by it’s primary key

Moving on we are done with the definition of our DynamoDB if you have any question pops it the comment section below.

Create Lambda functions

So my plan is we are going to have 4 lambda functions:

- Create Function
- List Function
- Update Function
- Delete Function

Let’s start with the Create Function. So our create function will do the below thing.

  1. get the POST request body
  2. extract the todo parameter from the body which is the only thing we need to create.
  3. check if the name exists in our database if exist raise error
  4. create the todo and return success or error message

Now open and paste the code below. I have describe the code using comment. If you don’t understand it ask me in the comment section.

Now we can continue to the next function which is List Function

So the Steps will be

  1. Get the POST request (am not going to consider customized pagination other than dynamodb default one)
  2. Get all the list of the todo
  3. Return the list

Open up the and append the below code. The code is documented and it is clear.

The next function will be the Update function. One thing in the update is to make things easy in the update method we only update the done field which indicated if the todo is completed or not. So we only allow to be completed the todo.

Open up the and append the code below too. The code is documented and it is clear

Now our last function will be 🥁🥁🥁 the DELETE function. hang on buddy we are almost finished with the code.

Open up the and append the code below too. The code is documented and it is clear

It is done. Our python code is done.

What is the next step ? you guessed it right connecting our python code to lambda function in the serverless.yml file.

Now open up serverless.yml and add the newly added code which is connecting our function to serverless lambda definition.

Now What remains ? I know we didn’t implement the todo-detail endpoint. This blog is just to get your hands dirty on serverless. There are many thing that can be improved but remember this is for the beginners.

Deploy the application

The exciting part of it is deployment. This is making our magical application available to the internet or to the whole world. So what command do we need to deploy ?


This answer might be the most longest command we have in this blog. YEAAH right ? 😜 😂

So make sure you are in a folder where serverless.yml file exists and execute the below command to fire off and deploy everything we have done.

serverless deploy


We have launched successfully


Now you can play with the api as long as you want but in the mean time we have to delete everything as this is for only educational purposes. When you feel like you are done playing with the API delete the stack using the below code.

sls remove

Github Repo for this blog is:

Next up the we will build a complex application with a series of blog.



  1. Explain where the huge performance of python 3.11 comes from and explain it in your word and in detail. Then Post the Answer in Linkedin post by Tagging me. You can find me Temkin Mengistu. Comment below the link of the post.


  1. You have use your own wording
  2. You can refer and do any research as much as you want.
  3. You have to tag me Temkin Mengistu on your linkedin post.
  4. You have to comment below the link of the linkedin post.
  5. Winner will be choosen by their idea and how strong it is.
  6. The contest will be closed by Dec 20, 2022.

There won’t be only one answer to this kind of question so enjoy.

if you like this blog please share it with your friends and colleagues. It will help me a lot.

Until next time, wish you the best.

Chapi Menge.