英文:
AWS CDK - Can I Pass LambdaInvoke's InputPath Prop Multiple JSON Paths?
问题
我发现new LambdaInvoke要求inputPath必须是一个字符串,所以无论我是否需要从多个地方传递event对象,我都需要一个Pass状态来实现它。
    this.organiseTheArrayAndId = new Pass(this, "组织数组和ID在一个对象中", {
      parameters: {
        "array": JsonPath.stringAt("$.productIdsArray"),
        "value": JsonPath.numberAt("$.productId.id")
      },
      resultPath: "$.organiseTheArrayAndId",
    });
    this.augmentProductIdArray = new LambdaInvoke(this, "将产品ID添加到数组中", {
      lambdaFunction: lambdaFunctionLocation,
      inputPath: "$.organiseTheArrayAndId",
    });
英文:
I find new LambdaInvoke requires the inputPath to be a string, so whether I need to pass the event an object from multiple places, I need a Pass state to make it happen.
    this.organiseTheArrayAndId = new Pass(this, "Organise the Array and Id Together In One Object", {
      parameters: {
        "array": JsonPath.stringAt("$.productIdsArray"),
        "value": JsonPath.numberAt("$.productId.id")
      },
      resultPath: "$.organiseTheArrayAndId",
    });
    this.augmentProductIdArray = new LambdaInvoke(this, "Add the Product ID To The Array", {
      lambdaFunction: lambdaFunctionLocation,
      inputPath: "$.organiseTheArrayAndId",
    });
Is there a more efficient way?
答案1
得分: 1
LambdaInvoke任务构造的payload属性允许您在调用函数时自定义函数接收的输入:
payload: sfn.TaskInput.fromObject({
    array: JsonPath.stringAt("$.productIdsArray"),
    value: JsonPath.numberAt("$.productId.id")
}),
英文:
The LambdaInvoke task construct's payload property lets you customize the input your function receives when invoked:
payload: sfn.TaskInput.fromObject({
    array: JsonPath.stringAt("$.productIdsArray"),
    value: JsonPath.numberAt("$.productId.id")
}),
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论