https://pulumi.com logo
#general
Title
# general
t

tall-librarian-49374

02/26/2019, 9:41 AM
Is there a way to bind
aws.apigateway.x.API
route to a
aws.lambda.Function
? @lemon-spoon-91807
l

lemon-spoon-91807

02/26/2019, 7:28 PM
Absolutely!
That's simply an EventHandlerRoute
so in your routes to API you would basically do this:
[{ path: "/whatever", method: "GET", eventHandler: yourAwsLambda }]
eventHandler
is typed as
eventHandler: aws.lambda.EventHandler<Request, Response>
And
EventHandler
is just an alias like so:
export type EventHandler<E, R> = Callback<E, R> | LambdaFunction;
where
LambdaFunction
is just
aws.lambda.Function
.
so, basically, we're saying: you can give us a JS callback, or a real aws Lambda.
t

tall-librarian-49374

02/26/2019, 8:05 PM
Oh, it was right in front of my nose and I haven't seen it!
thnx
l

lemon-spoon-91807

02/26/2019, 8:07 PM
absolutely!
we should advertise this functionality more. but it is our intent that any place we allow a JS callback, you should be able to pass a real AWS lambda.