有任何方法可以启动在本地.ASL文件中定义的状态机的执行? 这是我本地定义的状态机的一个示例(来自模板):
{
"Comment": "A state machine that does mock stock trading.",
"StartAt": "Check Stock Value",
"States": {
"Check Stock Value": {
"Type": "Task",
"Resource": "${StockCheckerFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 15,
"MaxAttempts": 5,
"BackoffRate": 1.5
}
],
"Next": "Buy or Sell?"
},
"Buy or Sell?": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.stock_price",
"NumericLessThanEquals": 50,
"Next": "Buy Stock"
}
],
"Default": "Sell Stock"
},
"Sell Stock": {
"Type": "Task",
"Resource": "${StockSellerFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 2,
"MaxAttempts": 3,
"BackoffRate": 1
}
],
"Next": "Record Transaction"
},
"Buy Stock": {
"Type": "Task",
"Resource": "${StockBuyerFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 2,
"MaxAttempts": 3,
"BackoffRate": 1
}
],
"Next": "Record Transaction"
},
"Record Transaction": {
"Type": "Task",
"Resource": "${DDBPutItem}",
"Parameters": {
"TableName": "${DDBTable}",
"Item": {
"Id": {
"S.$": "$.id"
},
"Type": {
"S.$": "$.type"
},
"Price": {
"N.$": "$.price"
},
"Quantity": {
"N.$": "$.qty"
},
"Timestamp": {
"S.$": "$.timestamp"
}
}
},
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 20,
"MaxAttempts": 5,
"BackoffRate": 10
}
],
"End": true
}
}
}
您可以使用
cat
将文件读为字符串。
aws stepfunctions --endpoint http://localhost:8083 create-state-machine --definition "$(cat local.asl.json)" --name "HelloWorld" --role-arn "arn:aws:iam::012345678901:role/DummyRole"
使用命令替代:
aws stepfunctions --endpoint http://localhost:8083 create-state-machine \
--definition "$(< local.asl.json)" \
--name "HelloWorld" \
--role-arn "arn:aws:iam::012345678901:role/DummyRole";
要了解更多信息,在man bash;