HI All
This is my first implementation of StateMachineFragment.
Goal: Attempting to create a class for re-usable lambda state. This class can take a parameter and pass this as payload to Lambda and the lambda will execute the right query based on the payload.
Below is my POC code to 'classs-ify' the lambda and the call to statemachine.
from aws_cdk import (
Duration,
Stack,
# aws_sqs as sqs,
aws_stepfunctions as _stepfunctions,
aws_stepfunctions as sfn,
aws_stepfunctions_tasks as _stepfunctions_tasks,
aws_lambda as _lambda,
)
from constructs import Construct
class SubMachine(_stepfunctions.StateMachineFragment):
def __init__(self, parent, id, *, jobTypeParam):
super().__init__(parent, id)
existingFunc = _lambda.Function.from_function_arn(self, "ExistingLambdaFunc", function_arn="arn:aws:lambda:us-east-1:958$#$#$#$:function:dummyFunction")
lambda_invoked = _stepfunctions_tasks.LambdaInvoke(self, "someID", lambda_function=existingFunc)
wait_10_seconds = _stepfunctions.Wait(self, "Wait for 10 seconds",
time=_stepfunctions.WaitTime.duration(Duration.seconds(10))
)
self._start_state = wait_10_seconds
self._end_states = [lambda_invoked.end_states]
def start_state(self):
return self._start_state
def end_states(self):
return self._end_states
class StepfunctionsClasStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
test_lambda_1 = SubMachine(self, "SubMachine1", jobTypeParam="one")
state_machine = _stepfunctions.StateMachine(self, "TestStateMachine",
definition=test_lambda_1,
# role=marketo_role
)
When I try and deploy this code, I get the following error:
jsii.errors.JSIIError: Cannot read properties of undefined (reading 'bindToGraph')
I am not sure where I am going wrong.
Thoughts?
Thanks