Is there anyway to config the layer when creating ...
# aws
r
Is there anyway to config the layer when creating event based lambda with crosswalk? Instead of creating a lambda function with pulumi/aws.
b
Can you give some more details on what you're trying to do?
r
Copy code
const endpoint = new awsx.apigateway.API("main", {
  routes: [
    {
      path: "/hello",
      method: "GET",
      eventHandler: handler(async (_e, _ctx, _cb) => {
        dosomething
      }),
    },
  ],
});
I need to provide layer for this handler.
b
You can pass in a
CallbackFunction
which can contains the
layers
property that you can use to pass in the ARN for up to 5 layers. Take a look at this link: https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/awsx/apigateway/#event-handler-route and scroll down to the code example with the
new aws.lambda.CallbackFunction
method in it
Basically you'd have something that looks like
Copy code
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

let endpoint = new awsx.apigateway.API("example", {
    routes: [{
        path: "/",
        method: "GET",
        eventHandler: new aws.lambda.CallbackFunction("test", {
            memorySize: 256,
            layers: [],
            callback: async (event) => {
                return {
                    statusCode: 200,
                    body: "<h1>Hello world!</h1>",
                };
            },
        }),
    }],
})
and the layers property you can use to specify the ARNs
Does that make sense?
r
Thanks.
Yeah just saw it. That’s what I am looking for.
Thanks a lot for your help. : )
b
no problem