jacob-meacham / serverless-plugin-bind-deployment-id

:link: Serverless plugin to bind the randomly generated deployment id to custom resources
MIT License
33 stars 7 forks source link

Fix plugin for use with Serverless 1.12.x #7

Closed ajkerr closed 7 years ago

ajkerr commented 7 years ago

Changes were made in Serverless 1.12 that changed how package/deploy work. This PR is designed to fix #6.

Based on some discussion towards the end of https://github.com/serverless/serverless/pull/3344, it appears that the lifecycle has changed such that you can still modify this.serverless.service.provider.compiledCloudFormationTemplate to make in-memory changes to the template, but modifying other things, such as this.serverless.service.resources.Resources, has no effect.

This fix seems to work. The only visible change that I could see was that the changes are not persisted to disk, but they do get uploaded and updated in CloudFormation.

There may be a better way/place to do this (perhaps by using new package lifecycle events), but this does seem to get the plugin working again.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 654adf9e0ed4bca9092ce7ec4c4d6e120ca83181 on ajkerr:serverless1-12 into 9d04575cb1071f47c74849a143b8203f5182af17 on jacob-meacham:master.

ajkerr commented 7 years ago

I've made another commit that basically restores the original code (except for the classname typo correction), and changes the hook from before:deploy:deploy to before:aws:package:finalize:mergeCustomProviderResources.

This allows us to modify the this.serverless.service.resources.Resources object before it get merged into the compiled CloudFormation template.

The plugin now seems to work as it did before, although it's probably not compatible with pre-1.12 versions of Serverless.

jacob-meacham commented 7 years ago

Looks good to me, thanks!

ajkerr commented 7 years ago

Great, thanks for merging! Would it be possible for you to push a new version to npm soon?

jacob-meacham commented 7 years ago

@ajkerr I just published 1.0.0 to NPM. Thanks!