codetheweb / serverless-step-functions-local

Run AWS step functions offline with Serverless
MIT License
16 stars 17 forks source link

Support state machine custom name #12

Open AlexBrel opened 2 years ago

AlexBrel commented 2 years ago

Hi,

Serverless provides a feature to add a custom name for the step function. https://www.serverless.com/plugins/serverless-step-functions#adding-a-custom-name-for-a-statemachine

However, the custom names are not supported by this plugin. Maybe, it's worth to add this?

Code proposal (line 121)

  async createEndpoints() {
    for (const stateMachineName in this.stateMachines) {
      const endpoint = await this.stepfunctionsAPI.createStateMachine({
        definition: JSON.stringify(this.stateMachines[stateMachineName].definition),
        name: this.stateMachines[stateMachineName].name || stateMachineName,    <----------changes
        roleArn: `arn:aws:iam::${this.config.accountId}:role/DummyRole`
      }).promise();

      // Set environment variables with references to ARNs
      process.env[`OFFLINE_STEP_FUNCTIONS_ARN_${endpoint.stateMachineArn.split(':')[6]}`] = endpoint.stateMachineArn;
    }
  }
codetheweb commented 2 years ago

Not using this package anymore myself but PRs are welcome. 👍

oneEyedSunday commented 1 year ago

@codetheweb what do you use now?

I have some problems with this package, albeit how helpful. Sometimes the step functions dont just run locally

An error occurred (StateMachineDoesNotExist) when calling the StartExecution operation: State Machine Does Not Exist: 'arn:aws:states:us-east-1:101010101010:stateMachine:ExampleWorkflow'

And sometimes they do

codetheweb commented 1 year ago

I don't use the serverless framework anymore. :)

The only time I did I was forced to via my job.

oneEyedSunday commented 1 year ago

Oh. I understand. I did get this to work. I had to do serverless offline start instead of just serverless offline

On Sat, 29 Oct 2022, 05:28 Max Isom, @.***> wrote:

I don't use the serverless framework anymore. :)

The only time I did I was forced to via my job.

— Reply to this email directly, view it on GitHub https://github.com/codetheweb/serverless-step-functions-local/issues/12#issuecomment-1295730395, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDNOO7WZNLQV7SH6PQGY5TWFSRX7ANCNFSM5ODOEIEA . You are receiving this because you commented.Message ID: @.*** com>