Kam*_*ski 12 amazon-web-services aws-cloudformation aws-step-functions aws-event-bridge
我正在使用 EventBridge 来触发步骤函数。CloudFormation 模板中的 EventBridge 规则如下所示:
JobStepFunctionTrigger:
Type: AWS::Events::Rule
Properties:
EventBusName: !GetAtt JobTaskEventBus.Name
Name: !Sub ${DeploymentName}-new-job-created
State: ENABLED
EventPattern:
source:
- !Sub ${DeploymentName}-my-service
detail-type:
- 'NEW_JOB'
Targets:
- Arn: !GetAtt JobOrchestrator.Arn
Id: !GetAtt JobOrchestrator.Name
RoleArn: !Ref MyAwesomeRole
Run Code Online (Sandbox Code Playgroud)
不幸的是,在这种情况下,步骤函数“执行名称”是随机生成的,因此很难将特定事件链接到特定步骤函数执行。在我的事件中,我有一个属性$.detail.id,$.detail.state我希望能够使用这些属性,以格式发出步骤函数执行名称${detail.id}_${detail.state}_someRandomValueToGuaranteeNameUniqueness,但阅读有关规则目标的文档,我不知道这是如何工作的...
今天这是不可能的。最简单的解决方法是重定向到已知的 API 网关端点 [1],然后使用 API 网关的转换来触发正确的步骤函数 [2]。
我对 API/GW 转换如何工作的了解有限,因此个人更喜欢使用 lambda 来调用正确的步骤函数。这也可能是您的备用选项。
[1] https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-api-gateway-target.html
[2] https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-data-transformations.html
| 归档时间: |
|
| 查看次数: |
3873 次 |
| 最近记录: |