Serverless Function Deployment Checklist
Pre-deploy and post-deploy checklist for AWS Lambda, Azure Functions and GCP Cloud Functions: IAM, env vars, memory sizing, timeouts, alarms and rollback.
Overview
A Lambda function that deploys cleanly to staging can still fail in production for reasons that have nothing to do with the code: an IAM role scoped to *, a timeout that kills the function mid-batch, or a missing dead letter queue that swallows failed invocations silently. This checklist exists to catch those failures before users do.
It covers everything you should verify when deploying a serverless function to production on AWS Lambda, Azure Functions, or Google Cloud Functions — from IAM scoping and environment variables to post-deploy alarms and rollback. If you need a deployment checklist for traditional infrastructure (VMs, containers, Kubernetes), use the generic deployment checklist template instead; if your concern is zero-downtime cutover for a stateful service, the zero-downtime deployment checklist is a better fit. For verification steps that apply to any stack after a release, see the post-deployment checklist template.
How to Use This Checklist
Work through the sections in order, and treat them as gates: a function doesn’t move to the next stage until every item in the current one checks out.
- Before merge: run section 1 (pre-deployment) as part of code review. IAM and configuration items are cheapest to fix here.
- Before deploy: run section 2 (infrastructure) against the staging environment. Most event source and API gateway mistakes only surface against real infrastructure.
- During deploy: follow section 3 (deployment procedure) and use a canary or gradual rollout whenever the function serves production traffic.
- After deploy: run section 4 (post-deployment verification) within the first 15–30 minutes, while errors are still cheap.
- If anything fails: jump to section 5 (rollback) and restore the last stable version before investigating.
Not every item applies to every function. A scheduled job with no HTTP trigger can skip 2.1; a function that reads public data with no downstream services needs far less IAM review than one writing to a payments table. Skip items deliberately, not by accident — write down why an item doesn’t apply so the next person doesn’t have to guess.
Provider Comparison: What Actually Differs
The checklist is provider-agnostic, but the limits and the tooling vocabulary aren’t. These are the differences that matter during deployment:
| Concern | AWS Lambda | Azure Functions | GCP Cloud Functions |
|---|---|---|---|
| Package size (zip) | 50 MB zipped / 250 MB unzipped | 100 MB (consumption) | 100 MB source / 32 MB direct upload |
| Container image | Up to 10 GB | Via container apps | Up to container registry limits |
| Max timeout | 15 minutes | 10 min (consumption) / 60 min (premium) | 9 min (1st gen) / 60 min (2nd gen HTTP) |
| Gradual rollout | CodeDeploy (canary/linear) | Deployment slots | Traffic splitting on revisions |
| Versioning model | Versions + aliases | Slots + deployment slots | Revisions per service |
| Native secrets store | Secrets Manager / SSM | Key Vault | Secret Manager |
| Tracing | X-Ray | Application Insights | Cloud Trace |
Three practical consequences of this table. First, Azure’s deployment slots and GCP’s traffic splitting give you canary deployments almost for free; on AWS you’ve to opt into CodeDeploy explicitly (section 3.2). Second, the 15-minute Lambda timeout is a hard ceiling — long-running work needs Step Functions or a queue-based fan-out, not a bigger timeout value. Third, package size limits differ enough that a function which deploys fine on Lambda can fail on Cloud Functions with the same dependencies.
1. Pre-Deployment Checklist
1.1 Function Configuration
- Memory size is set to the minimum that meets the p99 latency target — not the default, and not “whatever the template shipped with”
- Timeout is set to ~90% of the expected max execution time, so the function dies cleanly instead of hanging on a stuck dependency
- Concurrency limit is configured (reserved or provisioned) so a traffic spike can’t starve other functions in the account
- Runtime version is pinned —
nodejs20.x, not a floatinglatestthat upgrades under you - Handler signature matches what the runtime actually invokes (this breaks silently after refactors)
- Dead letter queue (DLQ) is configured for failed invocations; without it, async failures vanish
# AWS Lambda — serverless.yml
functions:
processOrder:
handler: src/handlers/processOrder.handler
memorySize: 512 # MB — tuned via profiling
timeout: 30 # seconds — 90% of max observed
reservedConcurrency: 100 # limit concurrent executions
runtime: nodejs20.x # pinned runtime
deadLetter:
queueName: processOrder-dlq
Cold starts dominate the latency budget for user-facing functions. If your p99 target is tight, review the cold start optimization recipe before locking memory and runtime choices — the 512 MB vs 1024 MB decision is usually a CPU allocation question, not a memory one.
1.2 IAM and Permissions
- Execution role has minimum required permissions — no
*:*or managedAWSLambda_FullAccess-style roles - Resource ARNs are scoped to specific resources, not
* - No hardcoded credentials in code or environment variables
- Secrets are loaded from Secrets Manager / Key Vault / Secret Manager at runtime, not baked into the deployment package
- Cross-service permissions are documented and approved — someone should be able to explain every statement in the role
# IAM role — least privilege
iam:
role:
statements:
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
Resource:
- !Sub "arn:aws:s3:::orders-bucket/*"
- Effect: Allow
Action:
- secretsmanager:GetSecretValue
Resource:
- !Sub "arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:order-api-key-*"
Wildcard ARNs are the single most common finding in serverless security reviews. For the full IAM audit pass, run the serverless security checklist alongside this one; for how secrets should be organized and rotated, see the secrets management guide.
1.3 Environment and Configuration
- Environment variables are set per stage (dev, staging, prod) — never a single shared config
- No secrets in plaintext environment variables; use
~truesecure strings or a secrets reference - Feature flags are configured for gradual rollout where the release is risky
- Log level is set appropriately (INFO for prod, DEBUG for dev)
- Region matches the deployment target — a wrong region deploys cleanly and breaks latency and data residency
environment:
LOG_LEVEL: ${self:custom.logLevel.${sls:stage}}
DB_HOST: ${ssm:/order-service/${sls:stage}/db-host}
API_KEY: ${ssm:/order-service/${sls:stage}/api-key~true} # secure string
FEATURE_NEW_PRICING: "true"
1.4 Code Quality
- Unit tests pass with coverage at or above the team threshold (80% is a reasonable floor)
- Integration tests pass against the staging environment
- Linting passes (ESLint, Prettier, or equivalent)
- No
console.login production code — use a structured logger so logs are queryable - Dependencies are pinned and audited (
npm audit --audit-level=highclean) - Bundle size is under 50 MB zipped (the Lambda direct-upload limit)
# Pre-deploy checks
npm run lint
npm run test:unit -- --coverage
npm audit --audit-level=high
npx serverless package --stage staging # verify package builds
2. Infrastructure Checklist
2.1 API Gateway / HTTP Trigger
- Route is configured and maps to the right handler
- Method (GET, POST, etc.) is correct — a wrong method returns 404s that look like a missing deployment
- CORS is configured for browser-facing endpoints
- Rate limiting is enabled at the gateway level
- Request validation schema is defined so malformed payloads never reach the function
- API key / auth is required for protected endpoints
events:
- http:
path: /orders
method: post
cors: true
request:
schemas:
application/json: ${file(schema/order-create.json)}
- http:
path: /orders/{id}
method: get
request:
parameters:
paths:
id: true # required
2.2 Event Sources
- Event source mapping is configured correctly (SQS, Kinesis, DynamoDB Streams, EventBridge)
- Batch size is tuned for the throughput/latency trade-off of the workload
- Retry policy is defined — max retries and backoff behavior
- Filter pattern is set so the function isn’t invoked for events it will discard anyway
- DLQ is attached for poison messages; without
ReportBatchItemFailuresa single bad record can block the whole batch
events:
- sqs:
arn: !GetAtt OrderQueue.Arn
batchSize: 10
maximumBatchingWindow: 5 # seconds
functionResponseTypes:
- ReportBatchItemFailures # partial batch response
filterPatterns:
- body: { eventType: [ "ORDER_CREATED" ] }
2.3 Observability
- Structured logging (JSON) is implemented — plain text logs are unsearchable at scale
- Distributed tracing is enabled (X-Ray, Application Insights, Cloud Trace)
- Custom metrics are emitted for business-level events, not just platform metrics
- Dashboards exist for the metrics someone will actually check during an incident
- Alarms are configured for error rate, duration, and throttle count — and they page someone
# CloudWatch alarms
resources:
Resources:
ProcessOrderErrors:
Type: AWS::CloudWatch::Alarm
Properties:
MetricName: Errors
Namespace: AWS/Lambda
Statistic: Sum
Period: 60
EvaluationPeriods: 1
Threshold: 5
ComparisonOperator: GreaterThanThreshold
AlarmActions:
- !Ref AlertTopic
3. Deployment Procedure
3.1 Deployment Steps
#!/bin/bash
# deploy.sh — serverless deployment pipeline
set -euo pipefail
STAGE="${1:-staging}"
SERVICE="order-service"
echo "=== Deploying $SERVICE to $STAGE ==="
# 1. Run tests
echo "Running tests..."
npm run test:unit
npm run test:integration -- --stage=$STAGE
# 2. Package
echo "Packaging..."
npx serverless package --stage $STAGE
# 3. Deploy
echo "Deploying..."
npx serverless deploy --stage $STAGE --verbose
# 4. Run smoke tests
echo "Running smoke tests..."
npm run test:smoke -- --stage=$STAGE --url=$(npx serverless info --stage $STAGE --verbose | grep "endpoint:" | awk '{print $2}')
# 5. Verify deployment
echo "Verifying deployment..."
npx serverless info --stage $STAGE
echo "=== Deployment complete ==="
3.2 Canary Deployment
On AWS, gradual rollout goes through CodeDeploy. The canary shifts a small percentage of traffic to the new version and rolls back automatically if the attached alarms fire:
# serverless.yml — gradual deployment via CodeDeploy
deploymentMethod: CodeDeploy
deploymentPreference:
type: Canary10Percent5Minutes
alarms:
- ProcessOrderErrors
- ProcessOrderDuration
rollbackEnabled: true
Canary10Percent5Minutes is a good default: it exposes 10% of invocations for five minutes, which is long enough for error-rate alarms to catch a regression but short enough that a bad deploy doesn’t sit half-rolled-out for an hour. For high-volume functions, prefer Linear10PercentEvery1Minute; for rare-invocation functions, a canary barely samples anything and a synthetic traffic check matters more than the rollout shape.
On Azure, the equivalent is deployment slots with a staged swap; on GCP, you split traffic between Cloud Run / Cloud Functions revisions with a --traffic flag or gcloud run services update-traffic. The checklist items are the same — only the mechanism changes.
3.3 IaC Tooling Variants
The examples above use Serverless Framework syntax because it’s the most common in this stack, but the checklist applies identically elsewhere:
- AWS SAM:
deploymentPreferencemaps toDeploymentPreferenceonAWS::Serverless::FunctionwithType: Canary10Percent5Minutes; alarms attach viaAlarmson the same property. - Terraform: there’s no built-in canary; you publish a version, point an alias at it, and use
aws_codedeploy_deployment_groupresources or weighted alias routing with a CI step to shift traffic. - Pulumi: same model as Terraform — versions, aliases, and explicit traffic shifting in code.
The trap to avoid in Terraform/Pulumi is updating the alias directly to the new version. That’s an instant cutover with no automatic rollback; if you want gradual rollout, you’ve to build the weighted-alias shift yourself.
4. Post-Deployment Verification
4.1 Health Checks
- Function is active — not pending, not failed
- Invoke test returns the expected response
- Logs are flowing to CloudWatch / Application Insights / Cloud Logging
- Metrics are emitting (invocations, errors, duration)
- Traces are visible in X-Ray / Application Insights
- DLQ is empty — check this explicitly; a growing DLQ is a silent failure
# Verify the function is deployed and healthy
aws lambda invoke \
--function-name order-service-prod-processOrder \
--payload '{"test": true}' \
--log-type Tail \
/tmp/response.json
# Check CloudWatch logs
aws logs tail /aws/lambda/order-service-prod-processOrder --since 5m
# Check error metrics
aws cloudwatch get-metric-statistics \
--namespace AWS/Lambda \
--metric-name Errors \
--dimensions Name=FunctionName,Value=order-service-prod-processOrder \
--start-time $(date -u -v-5M +%Y-%m-%dT%H:%M:%S) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%S) \
--period 60 \
--statistics Sum
4.2 Performance Verification
- p50 latency is within target (< 200 ms for typical API functions)
- p99 latency is within target (< 1 s, or whatever the SLO says)
- Cold start is acceptable (< 3 s for the first invocation)
- Memory utilization is below ~80% of allocated memory
- No throttles in the first 15 minutes — throttling on deploy usually means the concurrency estimate was wrong
If cold starts are the bottleneck, the serverless cold start runbook has the diagnostic sequence, and the connection pooling guide covers the other classic post-deploy surprise: a function that exhausts database connections under real concurrency for the first time.
4.3 Security Verification
- No secrets leaked in logs or responses — grep the first few log batches for known secret patterns
- IAM role attached is the scoped one, not a default broad role
- API endpoint requires authentication where it should
- Security headers are present on HTTP responses
- WAF rules are attached if the endpoint is public-facing
4.4 Cost Verification
A deploy that changes memory, concurrency or invocation patterns can quietly double the function’s monthly bill, so check cost while the traffic numbers are still fresh:
- Invocation count in the first hour matches the expected traffic — a misconfigured event filter or retry loop can multiply invocations
- GB-seconds per invocation is close to the pre-deploy baseline (duration × memory); a slower function on more memory compounds the cost
- Provisioned concurrency (if used) is actually utilized — an idle warm pool bills every hour
- Downstream costs are unchanged: API Gateway requests, NAT/data transfer, and log ingestion volume, which often costs more than the function itself
If the numbers drift, the serverless cost estimation template has the worksheet for projecting the monthly bill before it surprises finance.
5. Rollback Procedure
5.1 Quick Rollback
# AWS Lambda — roll back to the previous version
aws lambda update-alias \
--function-name order-service-prod-processOrder \
--name prod \
--function-version 42 # previous version number
# Verify the rollback took effect
aws lambda get-alias \
--function-name order-service-prod-processOrder \
--name prod
Alias-based rollback takes seconds because no code redeploys — the alias just points back at an already-published version. This only works if you deploy immutable versions rather than overwriting $LATEST, which is one more reason to version every production deploy.
5.2 Rollback Checklist
- Identify the last stable version number (keep it in the deploy log or CI output)
- Update the alias to point to the previous version
- Verify the function is serving traffic on the old version
- Confirm the error rate returns to baseline
- Notify the team — a silent rollback confuses everyone watching the dashboards
- Create an incident ticket for root cause analysis
- Schedule the post-mortem within 48 hours
Common Deployment Mistakes
These are the failures that show up again and again in serverless deploys, and none of them are code bugs:
- Deploying to
$LATESTwith no alias or version. Rollback becomes a redeploy of old code, which takes minutes and can fail on its own. Always publish a version and move an alias. - Timeout set to the provider maximum “just in case”. A 15-minute timeout on a function that should finish in 3 seconds means a stuck dependency burns money for 15 minutes per invocation and the alarm fires late. Set it near the observed max.
- Forgetting the DLQ on async invocations. Retries exhaust, the event is dropped, and there’s no record it ever happened.
- Reserved concurrency left at 0 from a previous test. The function throttles every invocation and looks broken while doing exactly what it was told to do.
- Secrets rotated in the vault but the function caches them. Anything loaded at cold start stays stale until the execution environment recycles. Either accept the staleness window or re-resolve secrets per invocation for critical keys.
- Testing against dev-shaped data. A function tuned on 1 KB payloads behaves very differently against the 500 KB payloads production sends.
Companion files: the serverless-function-deployment-checklist companion repo has the deploy pipeline as a runnable deploy.sh plus a reference serverless.yml that assembles the IAM, environment, event and canary config from this checklist into one file.
See Also
- Complete Guide to AWS Lambda in Production
- Serverless Security Checklist
- Complete Guide to Serverless Architecture
- Serverless Cold Start Runbook
- Minimize Cold Start Latency in Serverless Functions
References
- AWS Lambda quotas — official limits for package size, memory, timeout and concurrency
- AWS Lambda aliases and versions — how versioning and weighted aliases work
- Serverless Framework deployment preferences — canary and linear rollout configuration
- Azure Functions deployment slots — staged deployments and swaps
Frequently Asked Questions
How do I determine the right memory size for my Lambda function?
Start at 128 MB and run AWS Lambda Power Tuning against a realistic payload. It invokes the function at different memory settings and shows the cost/latency trade-off on a chart. Most functions land between 512 MB and 1 GB, but the answer depends on whether the function's CPU-bound — Lambda allocates CPU proportionally to memory, so a CPU-heavy function often gets faster and cheaper at higher memory even when it doesn't need the RAM. Profile with production-shaped data; a benchmark on a 1 KB test payload tells you almost nothing about a 500 KB real one.
What is the maximum deployment package size for serverless functions?
AWS Lambda allows 50 MB zipped / 250 MB unzipped for direct zip upload, and up to 10 GB as a container image. Azure Functions allows 100 MB on the consumption plan. GCP Cloud Functions allows 100 MB for source upload (32 MB for direct upload). If you hit the limit, the usual fixes are: strip devDependencies, enable tree-shaking or bundling (esbuild handles this well for Node), move large shared dependencies into a Lambda Layer, or switch to a container image. If your package is big because of a native binary or ML model, container images are usually the cleanest path.
Should I use provisioned concurrency for my serverless functions?
Use it when p99 latency is a hard requirement (< 100 ms) and traffic is predictable enough to keep the warm pool busy — it eliminates cold starts for the configured number of executions but you pay for them around the clock. Start small (5–10) and watch utilization. For spiky or rare traffic, scheduled warming or just accepting occasional cold starts is far cheaper. A practical middle ground on AWS is keeping provisioned concurrency only during business hours via scheduled scaling.
How do I handle database connections in serverless functions?
Put a pooler in front of the database — RDS Proxy on AWS, PgBouncer for PostgreSQL, or ProxySQL for MySQL — because each concurrent execution environment opens its own connections and a few hundred concurrent invocations can exhaust the database in seconds. Alternatively use a serverless-friendly data path like Aurora Data API, Cosmos DB, or Firestore. Whatever you choose, initialize the client outside the handler so it's reused across warm invocations; creating it inside the handler is the classic way to leak connections on every call.
What should I monitor after deploying a serverless function?
Four areas cover nearly everything: errors (rate and types), performance (p50/p99 duration, cold start percentage), concurrency (executions, throttles), and cost (invocations, GB-seconds). Sensible starting alarms: error rate above 1%, p99 duration above 2× baseline, any throttles at all, and concurrent executions above 80% of the reserved limit. Distributed tracing earns its keep here — when duration regresses, traces tell you whether the problem is the function or a downstream service.
When should I roll back versus roll forward?
Roll back when the deploy is actively breaking production and the fix isn't trivial: alias rollback takes seconds and restores a known-good state, which buys you time to investigate without an incident clock running. Roll forward only when the fix is small, tested, and faster to ship than the rollback would be to explain. If you're unsure, roll back — "we rolled forward and made it worse" is a much harder post-mortem to write.
Related Resources
Serverless Cost Estimation Template
Template for estimating serverless costs per workload: invocation pricing, GB-second math, data transfer, and the hidden line items that blow up estimates.
DocServerless Cold Start Runbook
Runbook for diagnosing and mitigating serverless cold starts: causes, measurement, optimization strategies (provisioned concurrency, warmers, initialization tuning), and monitoring with code examples for AWS Lambda, Azure, and GCP.
DocServerless Security Checklist
Security hardening checklist for serverless functions on AWS Lambda, Azure Functions and GCP Cloud Functions: IAM, secrets, input validation, dependencies, network and logging.
GuideComplete Guide to AWS Lambda in Production
Run AWS Lambda in production: cold starts, deployment patterns, connection pooling, observability, security, retries and cost tuning with code.
RecipeCold Start Optimization: AWS Lambda, Azure, Cloud Run
Reduce cold start latency across AWS Lambda, Azure Functions and Cloud Run: provisioned concurrency, SnapStart, min instances, lazy init and smaller packages.