Skip to content

lambda.invoke

Invoke a Lambda function.

Terminal window
Action.aws.lambda.invoke(lambdaFunction, inputProps?, actionProps?)

Usage

lib/MyStack.ts
10 collapsed lines
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs'
import { Action, ButtonizeApp, Input } from 'buttonize/cdk'
new ButtonizeApp(this, 'DemoApp')
.page('DemoPage', {
body: [
Input.text({
id: 'name',
label: 'What is your name?'
}),
Input.button({
label: 'Save to database',
onClick: Action.aws.lambda.invoke(
new NodejsFunction(this, 'MyLambda', {
handler: 'handler',
entry: path.join(__dirname, `lambdaHandler.ts`),
runtime: lambda.Runtime.NODEJS_18_X
}),
{
Payload: {
saveToDb: true,
userName: '{{name}}'
}
}
),
onClickFinished: Action.buttonize.app.changePage('DemoPage')
})
]
})

Props

You can also include props other than those mentioned below. Read more about the Invoke Command props in AWS SDK Docs.

Here, we only mention the most frequently used props.

Payload

Optional

object

Buttonize resolves variables in the Payload object and stringifies the whole object to JSON before sending the request to AWS.

{
Payload: {
someParameter: {
yes: false
},
userName: '{{name}}'
}
}