πŸ“Œ Summary

Develop and deploy an AWS Lambda function capable of securely connecting to a MySQL database hosted on a private EC2 instance and retrieving user activity data (e.g. from the locations table)

🧱 Architecture Overview


What is a Lambda Function?

AWS Lambda is like a smart helper that only wakes up to do a task when needed, so you don’t have to keep your computer on all day

Plus, it scales up automatically (AWS handles this) so no need to manage a separate server.

In our case, we use it to securely connect to the database hosted by a private EC2 instance.

Since the MySQL DB is inside a private VPC, we can deploy a lambda function inside the same VPC so that the lambda function can safely connect to the database through private networking.

Lambda can act as the middleman between those services and your database.

**React Native App**
     ↓ (HTTP POST with device_id)
**API Gateway**
     ↓ (Triggers Lambda function)
**AWS Lambda Function**
     ↓ (Executes SQL query using device_id)
**MySQL Database on EC2**
     ↓ (Returns 2000 latest rows to Lambda)
**AWS Lambda Function**
     ↓ (Builds and returns JSON response)
**API Gateway**
     ↓ (Returns HTTP response to app)
**React Native App**