question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

stepfunctions-tasks: StepFunctionsStartExecution should add AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID

See original GitHub issue

It’d be nice to have a property that’ll add the AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID to the input payload.

Use Case

This will make it easy to add the AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID to the input payload.

Proposed Solution

    const finalTransformExecution = new StepFunctionsStartExecution(
        scope,
        'Final Transform',
        {
            stateMachine: finalTransformSfn,
            integrationPattern: IntegrationPattern.RUN_JOB,
            // Proposed property, but horrible name. ;)
            addStartedById: true,
            outputPath: '$.Output',
        },
    );

Other

This would assist in removing some of the workarounds I’ve implemented to get this to work. https://github.com/aws/aws-cdk/issues/14777

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
BenChaimbergcommented, Sep 10, 2021

I agree this is nontrivial, but I still think possible. We have information about whether TaskInput is from a constructed object or directly taken from a JSON path. This means we can decide whether or not to support associateWithParent based on what is passed in for input. Something like:

class StepFunctionsStartExecution {
  constructor(...) {
    // ...
    if (this.props.associateWithParent && this.props.input?.type !== sfn.InputType.OBJECT) {
      throw new Error('Could not associate child execution with parent execution because input is taken directly from a JSON path (or a value for the `input` property was not provided). Use `sfn.TaskInput.fromObject` instead');
    }
  }

  _renderTask(): any {
    let input: any;
    if (this.props.associateWithParent) {
      const associateWithParentEntry = {
        AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID: sfn.JsonPath.stringAt('$$.Execution.Id'),
      };
      input = { ...this.props.input.value, ...associateWithParentEntry };
    } else {
      input = this.props.input ? this.props.input.value : sfn.TaskInput.fromJsonPathAt('$').value;
    }
    return {
      // ...
      Parameters: {
        Input: input,
        // ...,
     };
  }
}

I think a executionId static property of JsonPath is a great idea too! Just not a good replacement for this feature IMO

1reaction
BenChaimbergcommented, Jun 21, 2021

@hassanazharkhan yes, please feel free to open a PR for this feature. I think an appropriate name for the property would be associateWithParent and it should default to true

Read more comments on GitHub >

github_iconTop Results From Across the Web

class StepFunctionsStartExecution (construct) · AWS CDK
Add retry configuration for this state. This controls if and how the execution will be retried if a particular error occurs. bindToGraph(graph).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found