Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAM local API: "long lived" (server / daemon) mode #2535

Open
justinmk3 opened this issue Mar 23, 2022 · 2 comments
Open

SAM local API: "long lived" (server / daemon) mode #2535

justinmk3 opened this issue Mar 23, 2022 · 2 comments
Labels
feature-request New feature or enhancement. May require GitHub community feedback. lambda sam service:apigateway

Comments

@justinmk3
Copy link
Contributor

justinmk3 commented Mar 23, 2022

Problem

When local invoking a APIGateway Lambda, the Toolkit always started the local api only for the lifetime of the request or debug session. Customers may want the API to stay running so they can make other requests (for example via curl, postman, vscode-restclient, ...).

Use cases

  • Want to use a desktop application or arbitrary REST/HTTP client (postman, curl, ...) to send requests to the local API endpoint.
  • Don't want to craft different launch configs to make requests.
  • Avoids mounting Docker image on each request (minor performance benefit).

Expected behavior

  1. User can run the AWS: Start Local API command to start a local API.
    1. Toolkit does not stop the local API, it continues running until
      • vscode terminates
      • user re-runs AWS: Start Local API
      • user runs AWS: Stop Local API
  2. Toolkit tracks the APIs it has started.
  3. AWS “Local Explorer” shows a list of local endpoints.
    1. Endpoint context menu:
      1. Stop
      2. Copy URL
      3. Send request (?)
  4. When the Lambda code changes, Toolkit restarts the local API. (?)
  5. When vscode terminates, Toolkit prompts to stop any running local APIs (that it started).

Attach to an already-running local API

Requested in #2455 (comment) :

  1. While a sam local start-api endpoint is already running... :
    1. Introduce this invokeTarget.type = "api" variant:
      • no logicalId, api, payload
        • This launch config is purely to attach. It doesn't request. (Do we even need a launch config?)
    2. User can run AWS: Debug Local API to attach to an already running start-api
      • Toolkit lists all local API endpoints (impl: docker ps ?) ?
      • User chooses an endpoint + port
      • User chooses a coderoot or pathmapping
    3. Toolkit attaches vscode debugger
    4. User calls the endpoint using curl or a REST/HTTP client...
    5. vscode debugger session begins
@EmmaStott
Copy link

+1 on this. Ad-hoc invokes are good when I have a known payload I want to inspect, but sometimes I just want to fire up curl or Postman and make a bunch of requests against a running endpoint.

@justinmk3 justinmk3 changed the title SAM APIGW: "long lived" (server / daemon) mode SAM local API: "long lived" (server / daemon) mode Apr 1, 2022
@tdcsrq
Copy link

tdcsrq commented Jun 6, 2024

If it helps, I would like to respectfully +1 this as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or enhancement. May require GitHub community feedback. lambda sam service:apigateway
Projects
None yet
Development

No branches or pull requests

3 participants