Repository navigation
WIP: Add DRYrun support - #1808
Conversation
|
Thanks for the hard work you've put into here @johncmckim! IMHO as discussed in #1496 we should consider to switch to an own plugin as it encapsulates the functionality and implements dryrun in a more pluginish fashion (and not spread across multiple places). |
|
@pmuens @johncmckim I like the --dry-run option as it is pretty much used in this way in many tools (e.g. the AWS CLI) The only problem I see at the moment is that in the package plugin we also have the cleanup task which removes the whole .serverless folder. So you can't actually get access to the artefacts after Imho there are 2 options.
Thoughts? |
|
@flomotlik @pmuens I'm for the new plugin rather than a command option. With this implementation the flag doesn't actually dry run a deploy, it just builds artefacts. I think that makes the flag a little misleading. That said, I'll go with whatever you decide. In regards to the cleanup, when I ran this locally the What if we ran a cleanup before deploy rather than after. That way the |
How would this plugin/command work? It would simply package the artefacts, or what specifically would happen as part of the dryRun (that is different from what is happening here). Maybe we should rename
That sounds good to me. |
I like that one! Really makes sense (some kind of the simplest Aside: We need to add the However I would still vote for an extra plugin which encapsulates everything. Otherwise we'll end up with so many code spread across multiple files ( |
|
Ok so basically what we're talking about is actually not necessarily dryRun (here at least) but more |
|
One of the reasons why I like this not being a separate plugin is that its future proof. Basically if we update the way deployments happen we need to make dryRun work as well. If its a separate plugin or functionality we might not and it doesn't work correctly any more. |
|
@flomotlik you were right, it was still cleaning up resources. I didn't see it when I was testing as I hadn't setup my @pmuens @flomotlik just changed clean to occur before deploying. I've added a new lifecycle event In relation to the command vs argument, I think I just don't like the
Basically I think I do like Thoughts? I'm open to either a new plugin, |
| module.exports = { | ||
| writeCreateTemplateToDisk() { | ||
| const cfTemplateFilePath = path.join(this.serverless.config.servicePath, | ||
| '.serverless', `cf-template-create-${(new Date).getTime().toString()}.json`); |
There was a problem hiding this comment.
@pmuens @flomotlik I added a date to the name to keep it inline with the zip package.
Do you think a date is necessary here? It makes it hard to test and if the .serverless folder is being cleaned up it's probably unnecessary.
There was a problem hiding this comment.
Imho timestamp is good here so it doesn't overwrite anything in the future in case we change this implementation a bit and keep more things around.
|
Imho |
|
@flomotlik naming things is hard. I could get behind |
|
lets go with |
|
I've updated it to To use I could solve that with What would you prefer? |
|
@johncmckim thanks for the updates! 💃 I would do the simple solution / the less "hacky" one and vote for Will look into the PR in detail soon. Writing the CloudFormation template to disc might be related to this issue: So this PR could be a good preparation for #1740 🎉 |
|
@pmuens I actually like the clean step. Imho its something that sometimes needs to happen at the beginning of a deployment, so Imho introducing a separate step makes it easier for other providers in the future to integrate there. Also in favor of --noDeploy. I also tried it locally and it properly created the files and didn't deploy. From my perspective this is GTM, @pmuens could you review the code as well and merge in case the code is fine for you. |
|
Alright! Will look into this and merge once fully reviewed. Thanks @johncmckim for your work on this one! |
| }); | ||
| }); | ||
|
|
||
| it('should resolve if dry run', () => { |
There was a problem hiding this comment.
Could you update this test description (should resolve if no deploy)?
|
@johncmckim just reviewed it and added a few comments (mainly some renamings). Furthermore some documentation about this new feature would be great (some description on how to use it here: https://github.com/serverless/serverless/tree/master/lib/plugins/deploy and the new lifecycle here: https://github.com/serverless/serverless/tree/master/lib/plugins/deploy#provided-lifecycle-events) After those changes it's GTM from my side. Great work 🎉 ❤️ |
| .then(this.zipService), | ||
|
|
||
| 'after:deploy:deploy': () => BbPromise.bind(this) | ||
| 'deploy:clean': () => BbPromise.bind(this) |
There was a problem hiding this comment.
Could you move this above deploy:createDeploymentArtifacts so that correct order the hooks run through can be seen without looking into the deploy plugin.
|
@johncmckim great! Thanks for the updates 👍 . Will pull, test and merge it today! |
| .then(() => { | ||
| const msg = this.options.noDeploy ? | ||
| 'Deployment successful!' : | ||
| 'Did not deploy due to --noDeploy'; |
There was a problem hiding this comment.
We should probably remove the "Deployment successful" message since deployment never really happened.
There was a problem hiding this comment.
Ah I think I've got my messages the wrong way around. That would be confusing. I can update later today.
|
Another reason I really like this dry-run/no-deploy is that it allows for a CF diff plugin. First generate the new template without deploying and diffing against the running CF stack. This allows you to be more confident about what CF is going to perform during the deployment. |
|
@nicka although it's a separate issue I've been wondering about that too. Whether serverless could or should use CloudFormation Change Sets and the separation of build and deploy. With a few small changes you could support deploying pre-built artefacts. This would be helpful for projects like LambCI where people deploy the project into their own environment. |
|
@johncmckim Not sure about the CloudFormation Change Sets(maybe haven't used it enough). This could even be it's own plugin, to build and to deploy. For me personally simply seeing the diff between two templates would already be a useful addition. Although it might take some more skill to predict what will happen based on the diff, it could also help new users to get used to CF. And my mind is blown by LambCi 🚀 !!! |
|
thanks @johncmckim for this! |
|
Great job! Looking forward for beta2 question: will I be able with EDIT: Just checked out this PR's sources and yes, I'll be able to see the CloudFormation template with this 😆 |
|
Seems this PR is gone, I can't find the option of Will |
Pull Request Template ------------------------
Status:
In Development
Description:
Add's a dryRun flag as described in #1496
Todos: