serverless-associate-waf
serverless-associate-waf copied to clipboard
Support config-based values for version
Hi @MikeSouza, this plugin is great! I recently ran into a slight issue though and would like to attempt to address it with this PR if you are open to contributions.
Currently, if you try to pass in the version from a configuration file, the plugin will output the following regardless if V2
or Regional
is passed in.
Serverless:
-------- Invalid WAF Version Configuration --------
Version Defaulted to WAFRegional
This is because currently the validation is being handled in the constructor before the plugin is bound to the serverless configuration, so when ${this.config.version}
is getting checked, it results in the string literal that's passed in from the serverless template - in my case: ${{self:custom.WafVersion}}
.
Moving the verify steps and initializing this.wafVersion
within a bound function will interpolate the provided value properly. To do this and maintain the current behavior, I've moved the verifyValidWafConfig
function to be called as part of the before:package:cleanup
lifecycle hook.
When installing packages, I saw there were a few vulnerabilities reported, so I ran npm audit fix
to resolve what was found. The current version of serverless this package depends on is a couple majors behind, so I was wary of upgrading it from even 1.x to 2.x, in the event that it may introduce breaking changes to any consumers.