AWS Builder Center

Lambda is Just a Function — How I Stopped Being Scared of Serverless

I thought writing a Lambda function was impossible. Then I realized it's just a function with a different input/output format. Here's how I went from "I can't write code" to deploying a serverless AI chatbot on AWS.

A few weeks ago, I was preparing for a Japanese government internship (METI) and needed AWS skills. I had basic knowledge — I could launch an EC2, create an S3 bucket, set up a VPC, and manage IAM users. But the moment I saw "Lambda" in my project, I froze.
"I've never written a program outside of coding problems. How am I going to write a Lambda function?"
Then I opened the code of my serverless AI chatbot and read it line by line. And I realized something:
Lambda is just a function.
def lambda_handler(event, context):
message = json.loads(event['body'])['message']
response = requests.post(
GEMINI_URL,
headers={'x-goog-api-key': os.environ['API_KEY']},
json={'contents': [{'parts': [{'text': message}]}]}
)
reply = response.json()['candidates'][0]['content']['parts'][0]['text']
return {'statusCode': 200, 'body': json.dumps({'reply': reply})}
That's it. Three steps:
  1. Get input from  event  (it's a dict — I already knew dicts)
  1. Do the work (call an API —  requests.post() , one line)
  1. Return output in a specific format
The only "new" things were:
  •  event['body']  instead of a function parameter
  •  return {'statusCode': 200, 'body': ...}  instead of just  return answer 
  •  json.loads()  /  json.dumps()  for dict ↔ string conversion
That's it. No frameworks. No complex architecture. Just a function that AWS calls for you.
What I learned:
  • You don't need to be a "coder" to use serverless
  •  boto3  is just 2 lines:  import boto3  +  boto3.client('service') 
  •  requests  is just: send data to a URL, get response back
  • JSON is a dictionary. If you know dicts, you know JSON.
I'm not an expert. I can't write complex programs. But I can read this code, explain what it does, and deploy it. And for an intern — that's enough.
If you're stuck at the same place I was, here's my advice: read the code line by line. Don't try to write it first. Understand it. Then it'll make sense.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article