https://pulumi.com logo
#aws
Title
# aws
r

rhythmic-fireman-45324

01/27/2021, 3:36 PM
Is there anyway to config the layer when creating event based lambda with crosswalk? Instead of creating a lambda function with pulumi/aws.
b

brave-planet-10645

01/27/2021, 3:42 PM
Can you give some more details on what you're trying to do?
r

rhythmic-fireman-45324

01/27/2021, 4:00 PM
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

brave-planet-10645

01/27/2021, 4:08 PM
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

rhythmic-fireman-45324

01/27/2021, 4:35 PM
Thanks.
Yeah just saw it. That’s what I am looking for.
Thanks a lot for your help. : )
b

brave-planet-10645

01/27/2021, 4:36 PM
no problem