AWS CDK – 我可以传递 LambdaInvoke 的 InputPath 属性多个 JSON 路径吗?

huangapple go评论52阅读模式
英文:

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")
}),

huangapple
  • 本文由 发表于 2023年2月8日 22:01:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75386890.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定