Demonstrations
These step-by-step demonstrations walk you through complete workflows using the lambda-function module. Each demonstration includes prerequisites, detailed instructions, and verification steps.
Getting Started
To follow any demonstration, ensure you have:
- Prerequisites met:
Terraform >= 1.0, AWS CLI configured - Authenticate with the registry:
terraform login registry.patterneddesigns.ca - Clone the demonstration repository:
git clone <demo-repo-url> - Follow the step-by-step instructions below
Step-by-Step Guides
Deploy a Lambda function with API Gateway integration
Prerequisites
- AWS account with appropriate permissions
- Terraform >= 1.0
Step 1: Create the Function
module "api_handler" {
source = "registry.patterneddesigns.ca/patterneddesigns/lambda-function/aws"
version = "3.1.0"
function_name = "api-handler"
handler = "index.handler"
runtime = "nodejs20.x"
source_path = "./src/api"
timeout = 30
}
Step 2: Add API Gateway Trigger
Configure API Gateway to invoke the Lambda function.
Step 3: Deploy and Test
Run terraform apply and test your API endpoint.
Deploy a Lambda function that processes S3 events
Step 1: Create the Processor Function
module "s3_processor" {
source = "registry.patterneddesigns.ca/patterneddesigns/lambda-function/aws"
version = "3.1.0"
function_name = "s3-processor"
handler = "main.handler"
runtime = "python3.12"
source_path = "./src/processor"
timeout = 300
memory_size = 512
}
Step 2: Configure S3 Event Notification
Add S3 bucket notification to trigger the function.
Step 3: Test the Integration
Upload a file to S3 and verify the Lambda processes it.