

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: AWS Lambda
incomplete
2: Deploy Lambda
incomplete
3: Testing Lambda Functions
incomplete
4: API Gateway
incomplete
5: CloudWatch Log Groups and Viewing Lambda Logs
incomplete
6: Other Lambda Use Cases
incomplete
7: Final Cleanup
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Your Lambda function is deployed, now let's test it. Lambda provides several ways to invoke functions, and we'll explore a few.
When you test a Lambda function directly (via the CLI or AWS Console), you're not making an HTTP request to it. You're telling AWS to execute your code with a specific payload. Take a look at this diagram:
For our function, we need to simulate what API Gateway would send. When you invoke the function directly via the console, you're providing mock data. The IP address in your test event is not your real IP address; it's example data you're feeding to the function.
When you invoke a Lambda function, you'll notice different performance characteristics:
The logs will show an Init Duration on the first run, that's the cold start overhead. On subsequent runs (within a few minutes), you usually won't see INIT_START or Init Duration.
Cold starts can be frustrating for user-facing APIs. For truly latency-sensitive applications, you might want to keep functions warm (there are techniques like scheduled invocations or provisioned concurrency). But for many use cases, a 200-500 ms cold start is totally acceptable.
Test your Lambda function with different scenarios.
Cost check: Each Lambda invocation counts toward your free tier (1 million requests/mo). These test invocations will use about 10-20 requests total.
{
"requestContext": {
"identity": {
"sourceIp": "8.8.8.8"
}
},
"headers": {}
}
{
"requestContext": {
"identity": {}
},
"headers": {
"X-Forwarded-For": "198.51.100.99"
}
}
Answer the question.