【发布时间】:2019-08-23 20:33:41
【问题描述】:
我需要从 lambda 处理程序(用 java 编写)触发一个步进函数。 Lambda 可以通过 IAM 完全访问 AWS 步骤函数。
我已经尝试了以下,我没有看到错误,我得到了 200 Json,但是 step 函数没有执行。
这是我试过的代码:
StartExecutionRequest startExecutionRequest = new StartExecutionRequest();
startExecutionRequest.setStateMachineArn(stateMachineArn);
logger.info("stateMachineArn: "+stateMachineArn);
logger.info("stateMachineInputJson: "+stateMachineInputJson.toString());
AWSStepFunctionsAsync client = AWSStepFunctionsAsyncClientBuilder.defaultClient();
logger.info("startExecutionRequest: "+startExecutionRequest);
try {
logger.info("startExecutionAsync now");
client.startExecutionAsync(startExecutionRequest);
logger.info("startExecutionAsync done");
return new Response(200,"","stepFunctionTriggered");
}
catch (Exception e) {
logger.error("Exception while starting execution:"+ e);
return new Response(400,"","Error occured while executing Step Function");
}
Lambda 日志:
START RequestId: 2c6ac51d-1262-4fbf-acdc-ce706d5fbe56 Version: $LATEST
2019-04-02 18:17:56 2c6ac51d-1262-4fbf-acdc-ce706d5fbe56 INFO LaunchStepFunction:39 - stateMachineArn: arn:aws:states:xxxxx
2019-04-02 18:17:56 2c6ac51d-1262-4fbf-acdc-ce706d5fbe56 INFO LaunchStepFunction:40 - stateMachineInputJson: {}
2019-04-02 18:18:01 2c6ac51d-1262-4fbf-acdc-ce706d5fbe56 INFO LaunchStepFunction:43 - startExecutionRequest: {StateMachineArn: arn:aws:states:us-east-1:xxx:stateMachine:xxxx,}
2019-04-02 18:18:01 2c6ac51d-1262-4fbf-acdc-ce706d5fbe56 INFO LaunchStepFunction:45 - startExecutionAsync now
2019-04-02 18:18:01 2c6ac51d-1262-4fbf-acdc-ce706d5fbe56 INFO LaunchStepFunction:47 - startExecutionAsync done
END RequestId: 2c6ac51d-1262-4fbf-acdc-ce706d5fbe56
【问题讨论】:
标签: java amazon-web-services aws-lambda aws-step-functions