我正在使用 Node env lambda 中的 AWS 开发工具包;我试图在调用启动之前获取执行历史记录以检查正在运行的状态机。
所以我已经导入了SDK,可以启动状态机了
const AWS = require('aws-sdk');
const StepFunctions = new AWS.StepFunctions();
const startParams = {
stateMachineArn: 'STATE MACHINE ARN',
input: JSON.stringify({}),
};
StepFunctions.startExecution(startParams, (error, data) => {
if (error) {
console.log(
'THERE WAS AN ERROR STARTING THE STATE MACHINE. DETAILS IN THE FOLLOWING LOG'
);
console.log({ error });
} else {
console.log('Step function triggered successfully.');
console.log({ data });
}
});
控制台输出
Step function triggered successfully.
但是,当我尝试使用相同的 ARN检索状态机执行历史记录时,结果如下。
const AWS = require('aws-sdk');
const StepFunctions = new AWS.StepFunctions();
const retrieveParams = {
executionArn: 'STATE MACHINE ARN',
maxResults: 10,
reverseOrder: true,
};
StepFunctions.getExecutionHistory(retrieveParams, (error, data) => {
if (error) {
console.log(
'THERE WAS AN ERROR RETRIEVING EXECUTION HISTORY. DETAILS IN THE FOLLOWING LOG'
);
console.log({ error });
} else {
console.log('Execution history retrieved successfully.');
console.log({ data });
}
});
控制台输出 1
THERE WAS AN ERROR RETRIEVING EXECUTION HISTORY. DETAILS IN THE FOLLOWING LOG
控制台输出 2
{
error: InvalidArn: Invalid Arn: 'Resource type not valid in this context: stateMachine'
at Request.extractError (/opt/nodejs/node_modules/aws-sdk/lib/protocol/json.js:52:27)
at Request.callListeners (/opt/nodejs/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/opt/nodejs/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/opt/nodejs/node_modules/aws-sdk/lib/request.js:688:14)
at Request.transition (/opt/nodejs/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/opt/nodejs/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /opt/nodejs/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/opt/nodejs/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/opt/nodejs/node_modules/aws-sdk/lib/request.js:690:12)
at Request.callListeners (/opt/nodejs/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
at Request.emit (/opt/nodejs/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/opt/nodejs/node_modules/aws-sdk/lib/request.js:688:14)
at Request.transition (/opt/nodejs/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/opt/nodejs/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /opt/nodejs/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/opt/nodejs/node_modules/aws-sdk/lib/request.js:38:9) {
code: 'InvalidArn',
time: 2021-12-08T22:19:25.017Z,
requestId: 'REDACTED',
statusCode: 400,
retryable: false,
retryDelay: 63.25312941163477
}
}