如何在不删除日志的情况下更新 AWS CLI 中的 Step Function
How to update a Step Function in AWS CLI without Deleting the Logs
上个月我一直在使用 AWS,我需要知道如何在不更改文件名的情况下更新步进函数。
文档提供的在步骤函数中进行更改的方法是更改现有函数的名称并在文件中添加更改。但这将消除在 AWS CLI 中创建的日志。
例如,如果我将以下代码替换为其他代码,我必须更改项目的整体动态才能使它们出现在 AWS CLI 中
有人可以为此提供解决方案吗?
更新部分可以通过 AWS 配置命令完成。按照下面的命令,它会在执行日志中保留所有更改。
let aws = require('aws-sdk');
let roleArn = `roleARN goes here`;
let params = {
name: stepFunctionName,
roleArn: roleArn,
definition: JSON.stringify(definitionGoesHere),
};
let stepFunctions = new aws.StepFunctions();
stepfunctions.createStateMachine(params, function (err, data) {
if (err) {
console.log("error occured while creating the step function");
console.log(err, err.stack);
if (err.code === "StateMachineAlreadyExists" && err.statusCode === 400) {
let paramsUpdate = {
stateMachineArn: "stateMachine ARN for the existing stateMachine",
definition: JSON.stringify(definition),
loggingConfiguration: {
includeExecutionData: true,
},
roleArn: roleArn,
};
stepfunctions.updateStateMachine(
paramsUpdate,
function (error, updateData) {
if (error) {
console.log("error occured while updating the step function.");
console.log("Error", error.stack);
}
console.log("step function updated successfully");
console.log("response", updateData);
}
);
}
console.log(
"step function does not exist and the function creation and update faild in the process."
);
console.log("definition", definition for the stateMachine);
} // an error occurred
else console.log(data); // successful response
});
上个月我一直在使用 AWS,我需要知道如何在不更改文件名的情况下更新步进函数。
文档提供的在步骤函数中进行更改的方法是更改现有函数的名称并在文件中添加更改。但这将消除在 AWS CLI 中创建的日志。
例如,如果我将以下代码替换为其他代码,我必须更改项目的整体动态才能使它们出现在 AWS CLI 中
有人可以为此提供解决方案吗?
更新部分可以通过 AWS 配置命令完成。按照下面的命令,它会在执行日志中保留所有更改。
let aws = require('aws-sdk');
let roleArn = `roleARN goes here`;
let params = {
name: stepFunctionName,
roleArn: roleArn,
definition: JSON.stringify(definitionGoesHere),
};
let stepFunctions = new aws.StepFunctions();
stepfunctions.createStateMachine(params, function (err, data) {
if (err) {
console.log("error occured while creating the step function");
console.log(err, err.stack);
if (err.code === "StateMachineAlreadyExists" && err.statusCode === 400) {
let paramsUpdate = {
stateMachineArn: "stateMachine ARN for the existing stateMachine",
definition: JSON.stringify(definition),
loggingConfiguration: {
includeExecutionData: true,
},
roleArn: roleArn,
};
stepfunctions.updateStateMachine(
paramsUpdate,
function (error, updateData) {
if (error) {
console.log("error occured while updating the step function.");
console.log("Error", error.stack);
}
console.log("step function updated successfully");
console.log("response", updateData);
}
);
}
console.log(
"step function does not exist and the function creation and update faild in the process."
);
console.log("definition", definition for the stateMachine);
} // an error occurred
else console.log(data); // successful response
});