是否可以通过AWS API网关向AWS Step Function发出同步请求?
还是可以将AWS State Machine仅用于启动异步作业?
启动异步作业的安装程序可能包括以下内容:
ApiGatewayMethodStartExecution:
Type: 'AWS::ApiGateway::Method'
Properties:
...
Integration:
Type: AWS
Uri: arn:aws:apigateway:eu-north-1:states:action/StartExecution
RequestTemplates:
application/json: !Sub
- |
....
- StateMachineArn: !Ref AStateMachine
ApiGatewayMethodGetResult:
Type: 'AWS::ApiGateway::Method'
Properties:
...
Integration:
Type: AWS
Uri: arn:aws:apigateway:eu-north-1:states:action/DescribeExecution
RequestTemplates:
application/json: !Sub
- |
....
- StateMachineArn: !Ref AStateMachine
AStateMachine:
Type: 'AWS::StepFunctions::StateMachine'
...
不,如果直接调用step函数,则不会。但是,您可以通过将step函数包装在AWS Lambda中来模仿此行为。将端点配置为Lambda代理。让AWS Lambda触发一个/ AWS Step Function,并让AWS Lambda监视step函数以确定何时完成。完成后,让AWS Lambda返回任何内容,并将其发送给端点的调用方。所有这些机制都需要迅速发生,因为您在API网关上有30秒的超时时间。
在很多情况下,端点调用都会触发步进功能。我通常让端点调用Lambda,然后在step函数启动后再启动step函数。然后,我提供第二个端点,调用者可以使用该端点来查找该步进函数正在执行的操作的状态。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句