aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.41k stars 344 forks source link

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

Open justinmk3 opened 2 years ago

justinmk3 commented 2 years ago

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

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 https://github.com/aws/aws-toolkit-vscode/issues/2455#issuecomment-1085024260 :

  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 commented 2 years ago

+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.

tdcsrq commented 3 weeks ago

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