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

Step function names have changed #40

Closed
justinmchase opened this issue Apr 18, 2017 · 6 comments
Closed

Step function names have changed #40

justinmchase opened this issue Apr 18, 2017 · 6 comments

Comments

@justinmchase
Copy link

justinmchase commented Apr 18, 2017

Example serverless file:

service: example
plugins:
  - serverless-step-functions # 1.0
stepFunctions:
  stateMachines:
    foo:
      definition: ...

Expected
The generated lambda should be named: example-justin-foo

Actual
The generated lambda is FooStepFunctionsStateMachine-2C1XDD2NCZCR

Is there any way to control the name so I can have what it was before? Specifically for my usecases it must have the stage in it, it must start with the service name and it cannot have randomness in the name.

@justinmchase
Copy link
Author

It appears that I have to get the Arns of the state machines by using Ref: Name.... The problem I'm having is that referencing these arns from within the step function definitions themselves is not resolving the ref first. I need to setup some kind of dependency chain probably, I'll update here if I figure that out.

@horike37
Copy link
Collaborator

horike37 commented Apr 18, 2017

@justinmchase
Thank you for the opening this issue! The cause that the deployment has became through CloudFormation. Unfortunately it can't directly specify the name of statemachine, so actually the name generated automatically by CF. But TBH I haven't thought that much about it yet to provide a better proposal.

I think that maybe resolve the problem by implementing global arn parser which is discussed in the following issue
serverless/serverless#3212

@horike37 horike37 closed this as completed May 2, 2017
@justinmchase
Copy link
Author

justinmchase commented May 2, 2017

For posterity I think that the way to get the name is something like this:

service: example
plugins:
  - serverless-step-functions

provider: ...

functions:
  step_executor:
    handler: handler.step_executor
    environment:
        example_arn: ${self:resources.Outputs.Example.Value} # The resolved arn

stepFunctions:
  stateMachines:
    Example:
      definition: ${file(example.yml)}

resources:
  Outputs:
    Example:
      Description: The ARN of the example state machine
      Value:
        Ref: ExampleStepFunctionsStateMachine # resolves the step function arn by ref

@horike37 horike37 reopened this May 2, 2017
@justinmchase
Copy link
Author

I'm not sure there is anything you need to do for this actually, so closing it is probably fine. But for anyone who comes here wondering how to deal with it they can use the snippet above to get the ARN.

@horike37
Copy link
Collaborator

horike37 commented May 20, 2017

@justinmchase
Thank you for this!!! That's sound great!
I just tried this snippet and work fine! I couldn't get this idea..

I will add this to README as tips.

@jeremycare
Copy link

If other people come here,
It didn't work for me because I had:
randomName-${self:provider.stage} instead of randomName${self:provider.stage}

Looks like - is not accepted here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants