-
-
Save sviatoslav-lebediev/58f97ee5c316fd3ab35f7dad7c2f06dc to your computer and use it in GitHub Desktop.
Serverless Plugin Lifecycle Events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// This plugin will bind to all available lifecycle events and print them out as they are invoked | |
class LifecyclePrinter { | |
constructor(serverless, options) { | |
this.serverless = serverless; | |
this.options = options; | |
this.provider = this.serverless.getProvider('aws'); | |
this.hooks = {}; | |
for (let event in this.serverless.pluginManager.hooks) { | |
if (event.startsWith('before:') || event.startsWith('after:')) { | |
this.hooks[event] = this.hook.bind(this, event); | |
} | |
else { | |
const beforeEvent = 'before:' + event; | |
this.hooks[beforeEvent] = this.hook.bind(this, beforeEvent); | |
const afterEvent = 'after:' + event; | |
this.hooks[afterEvent] = this.hook.bind(this, afterEvent); | |
} | |
} | |
} | |
hook(event) { | |
console.log(' IN: %s', event); | |
} | |
} | |
module.exports = LifecyclePrinter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/sandbox> sls deploy | |
IN: before:package:cleanup | |
IN: before:aws:common:validate:validate | |
IN: after:aws:common:validate:validate | |
IN: before:aws:common:cleanupTempDir:cleanup | |
IN: after:aws:common:cleanupTempDir:cleanup | |
IN: after:package:cleanup | |
IN: before:package:initialize | |
IN: after:package:initialize | |
IN: before:package:setupProviderConfiguration | |
IN: after:package:setupProviderConfiguration | |
IN: before:package:createDeploymentArtifacts | |
Serverless: Packaging service... | |
Serverless: Excluding development dependencies... | |
IN: after:package:createDeploymentArtifacts | |
IN: before:package:compileFunctions | |
IN: after:package:compileFunctions | |
IN: before:package:compileEvents | |
IN: after:package:compileEvents | |
IN: before:package:finalize | |
IN: before:aws:package:finalize:mergeCustomProviderResources | |
IN: after:aws:package:finalize:mergeCustomProviderResources | |
IN: before:aws:package:finalize:saveServiceState | |
IN: before:aws:common:moveArtifactsToPackage:move | |
IN: after:aws:common:moveArtifactsToPackage:move | |
IN: after:aws:package:finalize:saveServiceState | |
IN: after:package:finalize | |
IN: before:aws:common:validate:validate | |
IN: after:aws:common:validate:validate | |
IN: before:deploy:deploy | |
IN: before:aws:deploy:deploy:createStack | |
IN: after:aws:deploy:deploy:createStack | |
IN: before:aws:deploy:deploy:checkForChanges | |
IN: after:aws:deploy:deploy:checkForChanges | |
IN: before:aws:deploy:deploy:uploadArtifacts | |
Serverless: Uploading CloudFormation file to S3... | |
Serverless: Uploading artifacts... | |
Serverless: Uploading service .zip file to S3 (15.05 KB)... | |
IN: after:aws:deploy:deploy:uploadArtifacts | |
IN: before:aws:deploy:deploy:validateTemplate | |
Serverless: Validating template... | |
IN: after:aws:deploy:deploy:validateTemplate | |
IN: before:aws:deploy:deploy:updateStack | |
Serverless: Creating Stack... | |
Serverless: Checking Stack create progress... | |
......................................... | |
Serverless: Stack create finished... | |
IN: after:aws:deploy:deploy:updateStack | |
IN: before:aws:info:validate | |
IN: after:aws:info:validate | |
IN: before:aws:info:gatherData | |
IN: after:aws:info:gatherData | |
IN: before:aws:info:displayServiceInfo | |
Service Information | |
service: sandbox | |
stage: dev | |
region: us-west-2 | |
stack: sandbox-dev | |
IN: after:aws:info:displayServiceInfo | |
IN: before:aws:info:displayApiKeys | |
api keys: | |
None | |
IN: after:aws:info:displayApiKeys | |
IN: before:aws:info:displayEndpoints | |
endpoints: | |
GET - https://<redacted>.execute-api.us-west-2.amazonaws.com/dev/f1 | |
GET - https://<redacted>.execute-api.us-west-2.amazonaws.com/dev/f2 | |
IN: after:aws:info:displayEndpoints | |
IN: before:aws:info:displayFunctions | |
functions: | |
function1: sandbox-dev-function1 | |
function2: sandbox-dev-function2 | |
IN: after:aws:info:displayFunctions | |
IN: before:aws:info:displayStackOutputs | |
IN: after:aws:info:displayStackOutputs | |
IN: after:deploy:deploy | |
IN: before:deploy:finalize | |
IN: before:aws:deploy:finalize:cleanup | |
IN: after:aws:deploy:finalize:cleanup | |
IN: after:deploy:finalize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment