Skip to content

Conversation

@vicheey
Copy link
Contributor

@vicheey vicheey commented Nov 3, 2025

Summary

Which issue(s) does this change fix?

Enables developers to specify a subset of Lambda functions from the template when starting local development servers.

Why is this change necessary?

This is for improving development efficiency by reducing resource usage and startup time for large SAM applications.
When working with SAM templates containing many Lambda functions, developers often only need to test a few functions at a time. Currently, sam local start-lambda initialize containers for ALL functions in the template when using --warm-containers EAGER, which:

  • Consumes unnecessary system resources (memory, CPU, disk)
  • Increases startup time
  • Makes local development slower and less efficient

This change allows developers to specify exactly which functions they want to work with, similar to how they can already target specific functions with sam local invoke.

How does it address the issue?

Adds function name filtering capability to sam local start-lambda commands so that users can now run sam local start-lambda Function1 Function2

CLI Changes

  1. InvokeContext (invoke_context.py):
    • Accepts function_logical_ids parameter
    • Validates function names exist in template
    • Passes function logical id list to function and API providers
  2. SamFunctionProvider (sam_function_provider.py):
    • Filters functions during extraction based on provided names
    • Matches against function_id, name, and FunctionName property
    • Maintains filter during template refresh in warm container mode

Testing

  • Added unit tests for modified components
  • Added integration tests for both start-lambda and start-api commands with explicit function list
  • Tests cover validation, filtering, warm/cold containers, and error cases
  • Updated existing unit tests to work with new parameter

What side effects does this change have?

Additive Feature

  • Reduced memory and CPU usage when working with subset of functions
  • Faster startup time for local development servers
  • Better developer experience for large SAM applications
  • Function name validation happens at startup (fails fast with clear error)
  • File watcher still monitors entire template (necessary for detecting structural changes)
  • Only specified functions have containers initialized and code watched

Backward compatibility

  • Additive feature and fully backward compatible - existing workflows unchanged

Mandatory Checklist

PRs will only be reviewed after checklist is complete

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@vicheey vicheey marked this pull request as ready for review November 3, 2025 21:06
@vicheey vicheey requested a review from a team as a code owner November 3, 2025 21:06
@vicheey vicheey changed the title feat: allow explicit listing of function ids for local start-* command feat: allow explicit listing of function ids for local start-lambda command Nov 4, 2025
@vicheey vicheey force-pushed the feat-allow-specifying-functions-local-start-command branch from c100003 to 3b5fbbb Compare November 4, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant