Python in AWS Lambda Function with Layers and Deployed with AWS CDK

Codescrum
9 min readApr 23, 2020

Serverless architecture is a cloud computing execution model where we do not worry about specific machines, their configurations, workload distribution, allocation or maintainability. The idea is to abstract all of that away so that we need only worry about our business logic and the end-user experience.

In this computing model, we are generally billed for the number of operations of a service or the time that we use a resource, i.e. we pay for the amount of memory, disk space or seconds in an HTTP request. In this post, we will teach you how to deploy a functionality that is accessible through an HTTP endpoint, its logic code in an Amazon Web Service (AWS) Lambda function and the data saved in a NoSQL database. You will find a link to the source code repository at the end of the post.

This is the architecture diagram of our example application that we will implement:

Infrastructure definition with AWS CDK

To create the stack step by step, we will use Typescript as the default language to write the infrastructure and Python language for the Lambda logic:

--

--

Codescrum

We make the unthinkable possible by understanding our client company’s problems, envisioning how software solves them and delivering the right result.