memory_size
Amount of memory in MB allocated to the function
Example
memory_size = 128Memory Configuration
Lambda allocates CPU power proportionally to memory. More memory = more CPU = potentially faster execution.
| Memory (MB) | vCPU Allocation |
|---|---|
| 128-896 | Partial vCPU |
| 1024 | ~1 vCPU |
| 1769 | 1 vCPU |
| 3538 | 2 vCPUs |
| 10240 | 6 vCPUs |
Best Practices
- Start with 128MB and increase based on CloudWatch metrics
- Monitor
DurationandMemory Usedmetrics - Consider cost vs. performance trade-offs
- Use AWS Lambda Power Tuning for optimization
Full Module Example
module "lambda_function" {
source = "registry.patterneddesigns.ca/patterneddesigns/lambda-function/aws"
version = "0.1.0"
# memory_size
memory_size = 128
# Other required inputs
function_name = my-resource
runtime = python3.9
handler = example-value
source_path = /path/to/resource
}