← All one-liners·#036·ops·aws·power

Lambda: every function ranked by memory + timeout

Account-wide Lambda audit: who's running with 10GB memory and 15-minute timeouts? Catches over-provisioned functions in one query.

Setup
  • → brew install awscli
  • → aws configure
Cost per run
free
The one-liner
$ aws lambda list-functions --max-items 500 \
  | jq -r '.Functions
             | sort_by(-.MemorySize)
             | .[]
             | [.MemorySize, .Timeout, (.Runtime // "-"), .FunctionName] | @tsv' \
  | awk -F'\t' '{ printf "%5d MB  %4ds  %-14s  %s\n", $1, $2, $3, $4 }'
What each stage does
  1. [01] awsaws lambda list-functions --max-items 500
    Lists every function with its config. --max-items caps the result — 500 is enough for almost every account.
  2. [02] jqjq -r '.Functions | sort_by(-.MemorySize) | …'
    Sort by memory descending — over-provisioned functions float to the top. Add `select(.MemorySize > 3000)` to filter directly.
  3. [03] awkawk -F'\t' '{ printf …'
    Fixed-width formatting: %5d memory, %4ds timeout, %-14s runtime (left-aligned), then function name. Reads as a real table.
Expected output (sample)
10240 MB  900s  python3.11    reprocess-bulk-worker
10240 MB  900s  python3.11    measurement-simulator
 4096 MB  300s  python3.11    pdf-render
 3008 MB  180s  nodejs20.x    image-resize
 1024 MB   30s  python3.11    api-handler
  512 MB   30s  python3.11    health-check
Caveats & tips
  • Add `--query 'Functions[?MemorySize>`3008`]'` server-side if you have >500 functions to avoid pagination headaches.
  • Pipe through `gemini -p "Suggest right-sizing per function based on memory and timeout. Format as a markdown table."` for actionable resizing advice.