aghadiry / serverless-cloudfront-invalidate

Serverless plugin that allows you to invalidate Cloudfront Cache
MIT License
29 stars 22 forks source link

feat: Add multiple invalidations based on stages #19

Closed AllegraChen closed 3 years ago

AllegraChen commented 4 years ago

Before this PR, cloudfrontInvalidation was a single object under the custom section of serverless.yml file. There was no possible way to create invalidations for multiple CloudFront distributions. Therefore, the cloudfrontInvalidation object is turned into a list that can contain multiple distributions. The index.js file is modified to realize this feature. The function body in invalidate() is moved into ...cloudfrontInvalidation.forEach(). This feature is also mentioned in issue #8.

Besides, an option of create invalidations based on deployment stages was also not available. Hence, an optional stage property is added for each distribution element. An if statement that checks for stage property declaration and its matching with the provider's stage is added into invalidate() in index.js file.

The Setup example of cloudfrontInvalidation as a list and the Setup example of using the stage property of the elements of cloudfrontInvalidation is added to README.md file.

AllegraChen commented 4 years ago

Hi @aghadiry, could you take a look at this pull request?

coyoteecd commented 3 years ago

@aghadiry @AllegraChen next time please mention this kind of changes as BREAKING (so release a major, not a minor). I updated from 1.5 to 1.8 and builds started to fail due to the plugin assuming the config is an array.