Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Parameters" Parameter for Step Functions Tasks #2735

Closed
rrhodes opened this issue Jun 4, 2019 · 0 comments · Fixed by #2686
Closed

"Parameters" Parameter for Step Functions Tasks #2735

rrhodes opened this issue Jun 4, 2019 · 0 comments · Fixed by #2686
Labels
feature-request A feature should be added or improved.

Comments

@rrhodes
Copy link
Contributor

rrhodes commented Jun 4, 2019

Prior to CDK 0.32.0, I defined a Step Functions task to invoke a Lambda function passing in a couple of parameters:

import stepFunctions = require('@aws-cdk/aws-stepfunctions');

const unknownChannelTask = new stepFunctions.Task(this, "UnknownChannel", {
            resource: resultsLambda,
            parameters: {
                "data.$": "$",
                "status": "UNKNOWN_CHANNEL"
            }
        });

These parameters included existing data $ in the Step Functions, as well as introducing status = UNKNOWN_CHANNEL.

From CDK 0.32.0, this is refactored to

import stepFunctions = require('@aws-cdk/aws-stepfunctions');
import stepFunctionsTasks = require('@aws-cdk/aws-stepfunctions-tasks');

 const unknownChannelTask = new stepFunctions.Task(this, 'UnknownChannel', {
            task: new stepFunctionsTasks.InvokeFunction(resultsLambda)
        });

Now I think I'm no longer able to provide the parameters in this task definition. I've extended the InvokeFunction class to workaround this

import { InvokeFunction } from "@aws-cdk/aws-stepfunctions-tasks";
import { IStepFunctionsTask, StepFunctionsTaskProperties, Task } from "@aws-cdk/aws-stepfunctions";
import { IFunction } from "@aws-cdk/aws-lambda";

export class InvokeFunctionWithParameters extends InvokeFunction implements IStepFunctionsTask {
    parameters: { [key: string]: string };

    constructor(lambdaFunction: IFunction, parameters: { [key: string]: string }) {
        super(lambdaFunction);
        this.parameters = parameters;
    }

    bind(task: Task): StepFunctionsTaskProperties {
        return {
            ...super.bind(task),
            parameters: this.parameters,
        };
    }
}

Am I missing a simpler approach to this? If not, would it be possible to add support for parameters to the InvokeFunction class directly, rather than having to extend the class like above?

@rrhodes rrhodes added the feature-request A feature should be added or improved. label Jun 4, 2019
rix0rrr pushed a commit that referenced this issue Jun 18, 2019
This PR allows one to work with Task states that implement the callback service integration pattern.

Introduces a new class for integrating with Lambda in the new invocation style, since there are a number
of subtle differences with the old invocation style.

The supported task types are:

* `RunLambdaTask` (AWS Lambda)
* `SendToQueue` (AWS SQS)
* `PublishToTopic` (AWS SNS)

Closes #2658, closes #2735.
This was referenced Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
1 participant