aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 12 forks source link

Step function using `scheduler:*` actions errors out when run locally with stepfunctions-local #706

Closed abubakar-mehmood-runa closed 2 months ago

abubakar-mehmood-runa commented 5 months ago

Checkboxes for prior research

Describe the bug

I am running a Step Function using the AWS JS SDK v3 that gets and creates schedules with AWS EventBridge Scheduler. When I run it in the AWS account, I am able to run the step function.

However, when I set the endpoint to 'http://stepfunctions:8083', which is where the amazon/stepfunctions-local Docker container is running, I get the following error:

An error occurred while scheduling the state 'GetSchedule'. The provided ARN 'arn:aws:states:***:aws-sdk:scheduler:getSchedule' is invalid.;

Following this tutorial to run the step function locally, I have defined a mock (using this guide) for the step that invokes EventBridge Scheduler. With the mock, I get the following error:

An error occurred while scheduling the state 'GetSchedule'. Could not find scheduler:getSchedule as aws sdk. Please refer to https://docs.aws.amazon.com/step-functions/latest/dg/connect-supported-services.html for valid service ARNs.

The same errors occur if I invoke pipe:* resources instead of the scheduler:* ones.

For many other step functions I have that are not calling EventBridge Scheduler or any other services that were supported around the same time (Feb 2023, as listed here), the SDK and the mocking framework work fine.

Things I have tried:

Here is my step function:

{
  "Comment": "Sample step func that fetches a schedule",
  "StartAt": "GetSchedule",
  "States": {
    "GetSchedule": {
      "Type": "Task",
      "End": true,
      "Parameters": {
        "Name": "my_sched_name"
      },
      "Resource": "arn:aws:states:::aws-sdk:scheduler:getSchedule"
    }
  }
}

If EventBridge Scheduler is not supported as an integration by the stepfunctions-local Docker image, when can we expect them to be supported?

Meanwhile, is it possible to define a RuntimeExtension that mocks such actions and returns a generic successful response? I couldn't find any examples but had a look at some built-in extensions defined here, but couldn't figure out how to adapt them to my use case.

SDK version number

@aws-sdk/client-sfn@3.478.0, amazon/aws-stepfunctions-local:1.13.2

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.11.0

Reproduction Steps

  1. Create a schedule in EventBridge Scheduler named my_sched_name
  2. Define a step function that performs getSchedule. Example:
{
  "Comment": "Sample step func that fetches a schedule",
  "StartAt": "GetSchedule",
  "States": {
    "GetSchedule": {
      "Type": "Task",
      "End": true,
      "Parameters": {
        "Name": "my_sched_name"
      },
      "Resource": "arn:aws:states:::aws-sdk:scheduler:getSchedule"
    }
  }
}
  1. Initialise the step function to run on the locally running Step Function container (based on the amazon/stepfunctions-local Docker image). Example:
    this.name = name;
    this.definition = definition;
    const sfnConfig = {
      region: '<enter_region>',
      disableHostPrefix: true,
    };

    sfnConfig.endpoint = 'http://stepfunctions:8083';

    this.client = new SFNClient(sfnConfig);
  1. Initialise and send the StartExecutionCommand.
  2. Create and send the DescribeExecutionCommand command.

Observed Behavior

Expected Behavior

The step function should have a successful execution and return the schedule.

Possible Solution

Support scheduler:* actions in the stepfunctions-local Docker image.

Additional Information/Context

No response

abubakar-mehmood-runa commented 4 months ago

Hello, @RanVaknin. Would this be prioritised any time soon? Or is it better to post on AWS re:Post?

RanVaknin commented 3 months ago

Hi there,

This seems like a question to the Step Functions service team and not the SDK team. The fact that this works with the upstream resource and not with the docker image tells me that there might an issue with the image itself.

I have created an internal ticket with the Step Functions service team (#P121043693). Since this is not an issue with the SDK itself I'll be moving this to the Cross SDK issue for further tracking.

Thanks, Ran~

RanVaknin commented 2 months ago

This should now be supported with step functions local. Thanks again, Ran~

github-actions[bot] commented 2 months ago

This issue is now closed.

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.