Skip to content

Conversation

@ChristopheBougere
Copy link
Contributor

Replaces #90
This PR adds pre-deployment definition validation using asl-validator. The latter now supports intrinsic CF functions, which removes the need for serverless-pseudo-parameters support.

In contrast to #90 which adds a new command (sls validate stepf), here we automatically validate the state machine definitions during the deploy step. The main benefit is to avoid uploading and updating CloudFormation stack in order to detect and fix typos, so it can save some time when developing.

The feature is disabled by default, and can be enabled with a boolean:

stepFunctions:
  validate: true

I think this behaviour is better than the one in #90, but I'm happy to discuss it and revert it.
AFAIK it's working pretty well, but I haven't tested all the new step functions capabilities and associated services so please open issues/PR here if you experience issues.

@theburningmonk
Copy link
Collaborator

I agree that the validation should be done automatically. Is there any reason why it shouldn't be enabled by default?

Copy link
Collaborator

@theburningmonk theburningmonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ChristopheBougere
Copy link
Contributor Author

Is there any reason why it shouldn't be enabled by default?

No special reason, maybe we can start like this as a "beta" and turn it on by default in a month or so?

@theburningmonk
Copy link
Collaborator

@ChristopheBougere ok, no worries, can leave it as is so we're backward compatible

@horike37 this looks good from my perspective, can you have a look?

@horike37
Copy link
Collaborator

@ChristopheBougere @theburningmonk
Thank you for re-working on this 👍
The pre-deployment validation looks good but why don't you add sls validate stepf at this time?
Imo, the command would make writing the state machine definitions easy since it can do manual validation while writing it.

What do you think?

@ChristopheBougere
Copy link
Contributor Author

@horike37 I agree that it would be nice to have both possibilities.
At the same time, I think it is better to keep it simple in the code and have the same behavior in both cases.
I tried by adding this, which triggers the same functions than in package:compileFunctions: e2c9df9
But I am having this error:

TypeError: Cannot read property 'Resources' of undefined
    at ServerlessStepFunctions.translateLocalFunctionNames (/Users/christophe/my-service/node_modules/serverless-step-functions/lib/utils/aws.js:11:85)

Meaning that the variable this.serverless.service.provider.compiledCloudFormationTemplate hasn't been populated yet. I'm affraid that some package/deploy steps are missing to make the function name translations.
Maybe you have an idea?

@horike37
Copy link
Collaborator

@ChristopheBougere
Ah, ok. I re-thought that while testing this feature and sls validate stepf would be unnecessary. Because running the validation at the same time when running sls package.

@horike37
Copy link
Collaborator

@ChristopheBougere
Could you fix the conflicts? Afterwards, we can merge it.

@ChristopheBougere
Copy link
Contributor Author

@horike37 done 🙂

Copy link
Collaborator

@horike37 horike37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChristopheBougere
Thank you for the updates 👍 LGTM.

@horike37 horike37 merged commit d3703e1 into serverless-operations:master Aug 21, 2019
@theburningmonk
Copy link
Collaborator

🎉 This PR is included in version 2.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants