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

(stepfunctions): RuntimeError: machine.grantStartExecution is not a function #26090

Closed
ghost opened this issue Jun 22, 2023 · 1 comment
Closed
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@ghost
Copy link

ghost commented Jun 22, 2023

Describe the bug

I'm trying to set my statemachine as a target for eventbridge. The statemachine and Rule are fine when I build them individually (tested by synthesizing the template). The problem comes when I .add_target().

start_state = sfn.Pass(self, 'StartState',
            result=sfn.Result.from_object(
                {"hello": "ssc"}),
                result_path="$.hello"
        )
        # lambda and tasks 
        upload_to_bucket = _lambda.Function(
            self, "UploadToBucketFunction",
            runtime=_lambda.Runtime.PYTHON_3_9,
            handler="index.handler",
            code=_lambda.Code.from_asset(
                path.join("lambda", "upload_to_bucket"),
            ),
            initial_policy=[
                iam.PolicyStatement(
                    resources=["*"],
                    actions=["s3:PutObject"]
                )
            ]
        )

        first_step = tasks.LambdaInvoke(
            self, "UploadToBucketSFNInvoke",
            payload=sfn.TaskInput.from_object({
                "test": sfn.JsonPath.string_at("$.hello")
            }),
            lambda_function=upload_to_bucket
        )
        event_role = iam.Role(
            self, "EventRole",
            assumed_by=iam.ServicePrincipal("events.amazonaws.com")
        )

        sfnMachine = sfn.StateMachine(
            self, id, 
            definition=start_state.next(first_step)
        )

        trigger_sfn_rule = events.Rule(
            self, "TriggerSFNRule",
            description="Trigger Step Functions when a new domain document is uploaded",
            event_pattern=events.EventPattern(
                source=["aws.s3"],
                detail_type=["New object created"],
                detail={
                    "eventSource": ["s3.amazonaws.com"],
                    "eventName": ["ObjectCreated:Put"],
                },
                resources=[source_bucket_arn]
            ),
            schedule=events.Schedule.rate(
                Duration.days(1)
            )
        )
        sfnMachine.grant_execution(event_role)
        trigger_sfn_rule.add_target(
            targets.SfnStateMachine(
                start_state,
                input=events.RuleTargetInput.from_object({
                    "bucket_arn": output_bucket_arn,
                    # set file here
                })
            ),
            role=event_role
        )

Expected Behavior

The template should synthesize.

Current Behavior

I am getting this error message: RuntimeError: machine.grantStartExecution is not a function. When I check the docs for Typescript, grantStartExecution is indeed a function, so I'm not sure why it's saying otherwise.

Reproduction Steps

Add a statemachine as a target to an eventbridge rule, synthesize it, and it should repeat the error message.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.85.0

Framework Version

No response

Node.js Version

v16.13.1

OS

Mac OS

Language

Python

Language Version

Python 3.11.2

Other information

No response

@ghost ghost added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 22, 2023
@github-actions github-actions bot added the @aws-cdk/aws-stepfunctions Related to AWS StepFunctions label Jun 22, 2023
@ghost ghost closed this as completed Jun 22, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

0 participants