11

I'm using the EventBridge to trigger a step function. My EventBridge rule in the CloudFormation template looks as follows:

 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

Unfortunately the step function "execution name" is randomly generated in this case making it very difficult to link the specific event to the specific step function execution. in my event I have a property $.detail.id and $.detail.state I would love to be able to use these, to issue the step function execution name in the format ${detail.id}_${detail.state}_someRandomValueToGuaranteeNameUniqueness, but reading the docs about the rule targets I don't see how this would work...

Kamil Janowski
  • 1,872
  • 2
  • 21
  • 43
  • The doc says you need to add a lambda function. Are you sure that step function is supported? – Mithilesh_Kunal Oct 21 '20 at 08:01
  • it also says you can add a bunch of other things: https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-targets.html. I already use lambdas, sqs and step functions for my targets and they all work just fine. Now it's just about adding more visibility – Kamil Janowski Oct 21 '20 at 08:21
  • 1
    I am interested in finding a solution for this as well. I just want to add a prefix to the randomly generated UUID – Ramdev Nov 12 '20 at 15:27
  • afaik the solution doesn't exist. In my case the event that was published was directly related to a specific record in my DynamoDB, so in the end I defined a separate step in the step function that persists the execution id, since the step functions have the direct integration with the DynamoDB – Kamil Janowski Nov 13 '20 at 08:26
  • 1
    I have the same problem now, not defining the execution name. Those long random guides do not serve me any value but do extra logging inside the lambda function that executes as a part of the workflow execution. – Rati_Ge Oct 24 '22 at 20:59

1 Answers1

0

This isn't possible today. The simplest workaround is to redirect to an known API Gateway endpoint[1], and then use API-Gateway's transformations to then trigger the right step-functions[2].

I've got limited knowledge on how API/GW transformations work, so personally prefer using a lambda to call the right step-function. This could be your back up option as well.

[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

blr
  • 908
  • 4
  • 8