The problem: How does an application communicate with a backend?
Imagine a website that needs to retrieve product information or a mobile application that sends a user's details to a backend.
In both cases, the application needs a way to send requests, have them processed, and receive responses.
Traditionally, developers could run backend applications on servers they manage. That approach can work well, but it also introduces infrastructure responsibilities, including server maintenance, capacity planning, and scaling.
For a small project, I want to explore an alternative: using AWS services to receive requests and execute backend code without managing application servers myself.
This brings us to serverless architecture.
Exploring the services
Rather than introducing several services at once, I'll start with two that work together particularly well.
1. AWS Lambda: Running the code
AWS Lambda lets developers run code in response to events without managing the underlying servers.
For our project, Lambda will contain the Python function responsible for processing a request and returning a response.
The first version will be intentionally simple. We'll create a function that returns a JSON message rather than introducing a database or complicated business logic immediately.
The aim is to understand how the function executes and how another AWS service can invoke it.
2. Amazon API Gateway: Receiving HTTP requests
A Lambda function alone doesn't automatically give us a public HTTP endpoint.
Amazon API Gateway provides a way to create HTTP endpoints and connect them to backend integrations, including Lambda.
For this project, we'll explore an HTTP API with a route such as GET /hello .
When a client sends a request to that route, API Gateway forwards it through the configured integration to Lambda and returns the resulting response.
How will the architecture work?
The request flow we're exploring is:
Client → Amazon API Gateway → AWS Lambda → API Gateway → Client
Here's what happens at each stage:
- A client sends an HTTP request.
- API Gateway receives the request and routes it to the Lambda integration.
- Lambda executes the Python function.
- The function returns a response to API Gateway.
- API Gateway sends the HTTP response back to the client.
Our first endpoint will return a response similar to this:
{
"message": "Hello from AWS Lambda!",
"status": "success"
}
This isn't intended to be a complete application. It's a small starting point that lets us investigate the relationship between an HTTP endpoint and serverless compute.
Once that connection is understood, we can start exploring more interesting functionality.
Why start small?
It would be possible to introduce a database, authentication, multiple endpoints, and additional services from the beginning. However, doing everything at once would make it harder to understand which service is responsible for each part of the application.
Starting with one endpoint gives us a clear foundation.
It also raises useful questions for the next stages of the project:
- What happens when a request contains invalid data?
- What happens when the Lambda function encounters an error?
- How can we control who is allowed to invoke the API?
- How can we monitor failures and understand the cost of running the application?
These questions will guide the next articles in the series.
What's coming next?
In Week 2, I'll move from exploring the architecture to building the first version of the API. The plan is to create a Python Lambda function, connect it to an HTTP API in API Gateway, and test the endpoint.
I'll also examine the configuration required to connect the services and the permissions involved.
The aim is to understand not just what these services do individually, but how they work together in a practical application.
If you're also learning AWS, I'd be interested to hear how you approach a new service: do you start by understanding the architecture, or do you prefer experimenting with a small example first?
Loading article