agentleFS
LeanMeanCleanAppsLeanMeanCleanApps/CleanLambdaFunction/.agents/skills/lambda-emulator/SKILL.md

lambda-emulator

Skill0 starsChanged 10 days agoMITView on GitHub

How to try the function by hand with the Lambda runtime interface emulator in the AWS base image - docker compose, invoking with curl, choosing another function, sending an API Gateway HTTP API event, and reading errors. Use when you want to call the function as Lambda would, without deploying it.

  • Sends data out

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read the container's output with docker compose logs function.

    line 42
  2. Very specific:

    Stop it with docker compose down.

    line 44
  3. Very specific:

    Use the emulator in place of tests.

    line 48

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Lambda runtime interface emulator

The rule

The runtime image is built on the AWS Lambda .NET base image, which includes the runtime interface emulator. Running the image locally gives an endpoint that invokes the function exactly as Lambda would. docker-compose.yml maps it to port 7350 and turns sample data on. The image runs GetMovies unless you name another handler. Each function's handler string names the class Lambda Annotations generates for it, and src/Presentation/serverless.template lists them all.

Steps

  1. Start it: docker compose up -d --build.
  2. Invoke it by posting the request JSON to the emulator:

    curl -X POST http://localhost:7350/2015-03-31/functions/function/invocations \
      -d '{ "query": "global", "offset": 0, "limit": 5 }'
  3. To try another function, run the image with its handler string as the command:

    docker build . --target run --tag cleanlambdafunction:local
    docker run --rm -p 7350:8080 -e Database__SeedSampleData=true cleanlambdafunction:local \
      "Presentation::CleanLambdaFunction.Presentation.LambdaFunction.Handler_GetAuthors_Generated::GetAuthors"
  4. An HTTP API function (HttpGetMovies, HttpGetAuthors, HttpGetReviews) takes the API Gateway HTTP API payload 2.0 event, not the request record. Run it by its handler string as in step 3 and post the event API Gateway would send. The query string values are strings, as they are on the wire:

    curl -X POST http://localhost:7350/2015-03-31/functions/function/invocations \
      -d '{ "version": "2.0", "routeKey": "GET /movies", "rawPath": "/movies", "queryStringParameters": { "query": "global", "limit": "5" }, "requestContext": { "http": { "method": "GET", "path": "/movies" } } }'

    The answer has statusCode, headers and the JSON body as a string. Header names come back in lower case.

  5. Send a request that fails validation, such as { "limit": 0 }, and check the error's errorType and errorMessage. An HTTP API function answers a 400 with content-type: application/problem+json instead, and "limit": "0" in the query string shows it.
  6. Read the container's output with docker compose logs function. The runtime's start, invoke and error lines sit between our compact JSON events, one per line, at Debug because compose sets Serilog__MinimumLevel__Default (serilog). Each invocation's trace, metrics and logs also land in the Aspire dashboard at http://localhost:7352, through the collector compose starts beside the function (telemetry).
  7. Stop it with docker compose down.

Don't

  • Use the emulator in place of tests. Anything you check by hand gets a test (presentation-integration-tests).
  • Expose port 7350 beyond your machine. The emulator has no authentication.
  • Deploy to try a change. The emulator runs the same image Lambda would.

Check

docker compose up -d --build
curl -fsS -X POST http://localhost:7350/2015-03-31/functions/function/invocations -d '{}'
docker compose down

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.