AWS Lambda Error – Memory size must be between X MB and Y MB
A practical diagnostic guide for resolving Lambda memory configuration failures caused by invalid values, drift between IaC and console settings, or runtime-level misalignment during updates.
Problem
Your Lambda deploy or update fails immediately with:
An error occurred (InvalidParameterValueException) when calling the UpdateFunctionConfiguration operation:
Memory size must be between 128 MB and 10240 MB
or:
Invalid memory size: 64. Value must be between 128 MB and 3008 MB for this runtime.
Lambda rejects the configuration before the deployment completes.
- Memory value set below the minimum for the runtime
- IaC configuration out of sync with Lambda’s current limits
- Updating memory without updating architectural constraints
Clarifying the Issue
Each Lambda runtime enforces its own memory constraints, and AWS updates these limits from time to time. If your IaC template contains outdated values, deployments will fail immediately.
- Minimum is typically 128 MB, though older runtimes may require higher
- Maximum varies per region and runtime
- Memory must be an integer in megabytes
Why It Matters
Invalid memory settings stop deployments cold. No code is updated. No new version is published.
- CI/CD pipelines halt
- Console edits and IaC templates can drift
- Multi-stage deployments fail inconsistently
Key Terms
- Memory size – The RAM allocated to your Lambda function
- Configuration drift – IaC and deployed settings no longer match
- Runtime limits – AWS-enforced memory boundaries for each runtime
Steps at a Glance
- Confirm the memory error in CloudWatch Logs or CLI
- Check the function’s current memory setting
- Validate the allowed memory range for the runtime
- Compare IaC configuration against console settings
- Update memory size to a valid value
- Re-deploy the function configuration
- Re-invoke to confirm execution succeeds
Detailed Steps
Step 1: Confirm the memory error.
Start by checking the deployment or invocation logs:
aws logs tail /aws/lambda/my-function --since 5m
You should see:
Memory size must be between 128 MB and 10240 MB
This confirms a configuration failure. Now check the current setting.
Step 2: Check the function’s current memory setting.
Run:
aws lambda get-function-configuration \
--function-name my-function \
--query 'MemorySize'
If the value is invalid or outside the expected range, Lambda will reject updates. Next, confirm your runtime constraints.
Step 3: Validate the allowed memory range for the runtime.
Retrieve your function’s runtime:
aws lambda get-function-configuration \
--function-name my-function \
--query 'Runtime'
Most runtimes support:
128 MB → 10240 MB
If your IaC template uses older limits (like the former 3008 MB max), it must be updated. Now check for drift.
Step 4: Compare IaC configuration against console settings.
CDK:
memorySize: 64
SAM:
MemorySize: 64
Terraform:
memory_size = 64
If your IaC defines a value below the minimum, every deploy will fail. Now correct the memory value.
Step 5: Update memory size to a valid value.
Use a compliant value:
aws lambda update-function-configuration \
--function-name my-function \
--memory-size 512
This aligns the function with AWS requirements. Now re-deploy using your IaC tool.
Step 6: Re-deploy the function configuration.
CDK:
cdk deploy
SAM:
sam deploy
Terraform:
terraform apply
Once deployed, test it.
Step 7: Re-invoke to confirm execution succeeds.
aws lambda invoke \
--function-name my-function \
--payload '{}' \
out.json
If the function executes normally, the memory setting is fixed.
Pro Tips
Let the console guide you.
The AWS console prevents invalid memory values, while IaC may not.
More memory boosts performance.
Memory increases CPU allocation, which improves HTTP throughput and reduces timeouts.
Revisit limits occasionally.
AWS increases max memory every few years—old templates may silently violate new rules.
Conclusion
Invalid memory configuration stops Lambda deployments before they even begin. By verifying the allowed memory range, correcting outdated IaC values, and redeploying cleanly, you restore stable behavior and eliminate this class of configuration errors.
Aaron Rose is a software engineer and technology writer at tech-reader.blog and the author of Think Like a Genius.
.jpeg)

Comments
Post a Comment