Skip to content

Conversation

@djgrant
Copy link
Collaborator

@djgrant djgrant commented Feb 16, 2025

Currently, it is only possible to create lambdas using ES modules. This supports creating lambdas directly, referencing a module or zip path.

Changes

File buffer is stored in state again. Ideally this will be removed in the future, but for now this change decouples the lambda and zip resources (allowing a file resource to be a lambda dependency), and simplifies things.

The @notation/aws.iac lambda resource has a breaking change.

Example

import { lambda } from "@notation/aws/lambda";

export const externalJsLambda = lambda({
  id: "external-js",
  handler: "handler",
  code: {
    type: "file",
    path: "external/lambda.mjs",
  },
});

export const externalZipLambda = lambda({
  id: "external-zip",
  handler: "handler",
  code: {
    type: "zip",
    path: "external/lambda.zip",
  },
});

The lambdas can also be attached to other resource groups:

import { api, router } from "@notation/aws/api-gateway";
import { externalJsLambda, externalZipLambda } from "./lambda";

const helloApi = api({ name: "hello-api" });
const helloRouter = router(helloApi);

helloRouter.get("/hello1", externalJsLambda);
helloRouter.get("/hello2", externalZipLambda);

@djgrant djgrant merged commit 8119213 into main Feb 16, 2025
1 check passed
@djgrant djgrant deleted the standalone-lambda branch February 16, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants