serverless-step-functions icon indicating copy to clipboard operation
serverless-step-functions copied to clipboard

Validate as a standalone command or earlier in process

Open aackerson opened this issue 5 years ago • 6 comments

This is a Feature Proposal

Description

For feature proposals:

  • Currently, it appears that the step function definition validation only occurs when executing sls package. This is a long executing step, and it would be easier if we could have a way to validate the step function without going through sls package.
  • Recently, while writing a step function definition, I misspelled the key word "Resource" within a task definition. Although I had the validate flag set to true, the sls package command exited before it got to validate because the misspelling caused issues with the IAM role creation. This led to a long period of debugging to discover that the cause was a misspelled word, when, in theory, the validate step would have caught the problem well ahead of that stage and described the problem to us, thus saving us a lot of time.
  • Barring a standalone command for validate, moving the validate check to the start of the sequence of sls package steps would be equally useful. The earlier we can get a more human readable version of potential definition errors, the better.

Additional Data

  • Serverless Framework Core Version you're using: 1.46.1
  • The Plugin Version you're using: 2.7.0
  • Operating System: Mac OS

aackerson avatar Oct 23 '19 19:10 aackerson

@ChristopheBougere I think you had this in a PR at some point, but I remember you ran into some issue so it got taken out, do you remember what it was?

theburningmonk avatar Nov 01 '19 08:11 theburningmonk

Yes, correct. In order to validate the definition, we need various steps of the packaging to be done as pre-requirements (like compiling cloud formation templates). You can find more details here. Maybe I missed something, but it looked a bit overkill to implement for a low result (because we would have to trigger manually some steps, and in the end take as long as the normal packaging?).

ChristopheBougere avatar Nov 02 '19 10:11 ChristopheBougere

@ChristopheBougere While I understand that sls package encompasses the validation, I feel like package is more for getting something ready for deployment while validate is more more local development before we even get to the package state. Yes, under the hood we have to do a lot of the things we do for package anyway, but certainly the post-validate steps aren't necessary if we only care about validation.

Validation occurs within the compileStateMachines step here: https://github.com/horike37/serverless-step-functions/blob/master/lib/index.js#L112. Once we get out of validation, we don't need the actions that follow. Can we not add some sort of validate command that essentially runs until there and then stops? (code like this is not my area of expertise, so that's a serious question.)

aackerson avatar Nov 04 '19 20:11 aackerson

Hi @aackers, I guess you are right, we could probably gain some time with a specific command. I won't have much time at the moment to work on this but feel free to submit a PR 😉

ChristopheBougere avatar Nov 09 '19 09:11 ChristopheBougere

@ChristopheBougere Well, I guess that's fair. I'll have to see if I can also find some time to work on it. :-)

aackerson avatar Nov 11 '19 18:11 aackerson

Related https://github.com/serverless/serverless/issues/6562

aslafy-z avatar Feb 21 '20 11:02 aslafy-z