简体   繁体   English

AWS Step Functions 使用来自输入负载的属性作为参数

[英]AWS Step Functions Use Properties from input payload as parameters

I'm trying to use the AWS provided RDS CreateSnapshot step in a Step Function/State Machine.我正在尝试在 Step Function/State Machine 中使用 AWS 提供的 RDS CreateSnapshot 步骤。

The Lambda function that runs immediately before it outputs a simple payload with the two properties corresponding to the two parameters required for the CreateSnapshot step.在输出简单有效负载之前立即运行的 Lambda 函数,其中两个属性对应于 CreateSnapshot 步骤所需的两个参数。 In the console, this same payload is displayed as "Step Input" for the RDS CreateSnapshot step:在控制台中,此相同的有效负载显示为 RDS CreateSnapshot 步骤的“步骤输入”:

{
  "dbInstance": "mydb",
  "dbSnapshotName": "mydb-5-21-2022--17-21"
}

The RDS CreateSnapshot is defined as: RDS CreateSnapshot 定义为:

Create-Snapshot:
    Type: Task
    Resource: arn:aws:states:::aws-sdk:rds:createDBSnapshot
    Parameters:
      DbInstanceIdentifier: $.dbInstance
      DbSnapshotIdentifier: $.dbSnapshotName
    Next: SNS-Finished

I get the following error:我收到以下错误:

Error

Rds.RdsException
Cause

Invalid database identifier:  $.dbInstance (Service: Rds, Status Code: 400, Request ID: 18242626-0839-4e28-920e-1c6ea13c80c6)

It seems like I am missing something in my understanding of how to grab values from the input and map them to the Parameters.在我对如何从输入中获取值并将它们映射到参数的理解中,我似乎遗漏了一些东西。

I used the new AWS Workflow Studio to bootstrap creating my pipeline;我使用新的 AWS Workflow Studio 来引导创建我的管道; when adding the AWS provided RDS CreateSnapshot step, it sets the API parameters to be static inputs:添加 AWS 提供的 RDS CreateSnapshot 步骤时,它将 API 参数设置为静态输入:

在此处输入图像描述

However, in this case, the inputs should by dynamic since they will both be provided by the preceding steps in the pipeline and passed as input to this step.但是,在这种情况下,输入应该是动态的,因为它们都将由管道中的前面步骤提供,并作为输入传递给此步骤。 The syntax for those properties needs to be adjusted accordingly in the Parameters so they could be picked up/referenced correctly.需要在参数中相应地调整这些属性的语法,以便正确提取/引用它们。

Specifically, the Parameters for the RDS SDK API call needed " .$ " appended to the end of each of them.具体来说,RDS SDK API 调用的参数需要在每个参数的末尾附加“ .$ ”。

{
  "DbInstanceIdentifier.$": "$.dbInstance",
  "DbSnapshotIdentifier.$": "$.dbSnapshotName"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM