βοΈ The Power of Serverless: Scaling Without Servers
Hey Cloud Innovators π
Welcome to Day 33 of the #100DaysOfCloud Challenge!
Today, the Nautilus DevOps team is embracing Serverless Architecture. We are deploying a Python-based AWS Lambda function. This allows us to execute code in response to triggers without ever worrying about the underlying OS, patching, or scaling.
This task is part of my hands-on practice on the KodeKloud Engineer platform, which I highly recommend for anyone looking to master real-world DevOps scenarios.
π― Objective
- Create a Lambda function named
devops-lambda. - Use the Python runtime.
- Configure an IAM execution role named
lambda_execution_role. - Deploy code that returns a 200 Status Code and the message:
Welcome to KKE AWS Labs!.
π‘ Why Serverless is a Game-Changer
In traditional hosting, you pay for a server even when it's idle. With Lambda, you only pay for the milliseconds your code is actually running.
πΉ Key Concepts
FaaS (Function as a Service): You provide the code (the function), and AWS provides everything else. Itβs the ultimate abstraction of infrastructure.
Execution Role: Even serverless functions need permissions. The
lambda_execution_roletells AWS what other services (like CloudWatch Logs) this specific function is allowed to talk to.The Handler: This is the entry point in your code. When Lambda is triggered, it looks for a specific function (usually
lambda_handler) to begin execution.
π οΈ Step-by-Step: Deploying devops-lambda
Weβll move logically from IAM Setup β Function Creation β Code Deployment.
πΉ Phase A: Set Up the Execution Role
Before the function can run, it needs an identity.
- Navigate to IAM: Go to the IAM Console and select Roles > Create role.
- Trusted Entity: Select AWS Service and choose Lambda.
-
Permissions: Search for and attach the
AWSLambdaBasicExecutionRolepolicy. -
Role Name: Name it
lambda_execution_roleand click Create.
πΉ Phase B: Create the Lambda Function
- Navigate to Lambda: Open the AWS Lambda console and click Create function.
- Method: Select Author from scratch.
-
Basic Information:
-
Function name:
devops-lambda. - Runtime: Select the latest Python version.
-
Function name:
-
Permissions: Expand "Change default execution role," select Use an existing role, and choose your
lambda_execution_role. - Create: Click the orange Create function button.
πΉ Phase C: Code & Deploy
- Code Editor: In the Code tab, replace the default code with this snippet:
import json
def lambda_handler(event, context):
return {
'statusCode': 200,
'body': json.dumps('Welcome to KKE AWS Labs!')
}
- Deploy: Click the Deploy button to save and activate your changes.
β Verify Success
-
Create Test Event: Click the Test button. Give the event a name (e.g.,
MyTest) and click Save. - Execute: Click Test again to run the function.
-
Confirm: π If the execution result shows
Status: Succeededand you see your message in the body, mission accomplished!
π Key Takeaways
- π Rapid Deployment: From idea to a live, scalable endpoint in under 5 minutes.
- π‘οΈ Isolation: Each Lambda execution happens in its own secure, isolated container.
- π Statelessness: Lambda functions are stateless; they don't remember what happened in the previous run. Use S3 or DynamoDB if you need to save data!
π« Common Mistakes
-
Incorrect Return Format: If you are using Lambda with API Gateway, your function must return a dictionary with
statusCodeandbody. - Timeout Errors: The default timeout is 3 seconds. If your code takes longer, you need to increase this in the Configuration tab.
- Role Permissions: Forgetting to attach the logging policy means you won't see any error messages in CloudWatch.
π Final Thoughts
Youβve just deployed your first serverless application! This simple "Greeting" function is the first step toward building complex, event-driven systems that can power everything from image processing to real-time chat apps.
π Practice Like a Pro
If you want to try these tasks yourself in a real AWS environment, check out:
π KodeKloud Engineer - Practice Labs
Itβs where Iβve been sharpening my skills daily!
π Letβs Connect
- π¬ LinkedIn: Hritik Raj
- β Support my journey on GitHub: 100 Days of Cloud



Top comments (0)