AWS Lambda Hello World
This project demonstrates how to create, build, and test an AWS Lambda function locally using AWS SAM CLI and Docker.
The function responds with "Hello from Lambda!" when accessed through a local API endpoint.
Prerequisites
- 
AWS Account Required for full deployment to AWS. Optional if you only want to run the project locally using SAM CLI and Docker. 
- 
Python 3.11 Ensure Python is installed and added to your system PATH. (Optional) Create a virtual environment to manage dependencies. 
- 
Docker Desktop Needed to run Lambda functions locally via AWS SAM CLI. 
- 
AWS SAM CLI Used to build, test, and deploy your Lambda function. 
- 
(Optional) Python Virtual Environment Recommended to isolate project dependencies. 
Project Structure:
aws-lambda-hello/ +-- hello_world/ ¦ +-- app.py ¦ +-- requirements.txt +-- template.yaml +-- README.md
- hello_world/app.py? Main Lambda function code.
- hello_world/requirements.txt? Python dependencies.
- template.yaml? AWS SAM template that defines the Lambda function and API Gateway.
Follow these steps to build, validate, and run the Lambda function locally:
- 
Build the Lambda function sam build --use-container --template template.yaml 
- 
Validate the SAM template sam validate --template template.yaml 
- 
Invoke the Lambda function locally sam local invoke HelloWorldFunction 
- 
Start the local API Gateway sam local start-api 
- 
Test the endpoint Open your browser or run the following command in a terminal: curl http://127.0.0.1:3000/hello Expected output: {"statusCode": 200, "body": "Hello from Lambda!"} 
Notes:
- Make sure Docker is running before building or invoking the Lambda function.
- The folder structure is critical: hello_world/ must contain both app.py and requirements.txt.
- AWS SAM automatically handles dependencies during the build process.
License: This project is licensed under the MIT License.