Open forabi opened 6 years ago
@aghadiry are you maintaining this project? I also need an "enabled" property; assuming I submit a pull request, will you merge and publish it?
I've added a PR that might help you with this. https://github.com/aghadiry/serverless-cloudfront-invalidate/pull/21
With this PR you could disable the autoInvalidate
and in your CI pipeline invoke the serverless cloudfrontInvalidate
where required.
@mihaerzen I just added this plugin to my serverless project but the autoInvalidate
flag doesn't seems to work to me.
My configuration is:
cloudfrontInvalidate:
- distributionIdKey: "CDNDistributionId" #conditional, distributionId or distributionIdKey is required.
autoInvalidate: false # Can be set to false to avoid automatic invalidation after the deployment. Useful if you want to manually trigger the invalidation later. Defaults to true.
items: # one or more paths required
- "/*"
But the deploy pipeline is still invalidating twice.
Looking into the code i'm wondering if this line is correct https://github.com/aghadiry/serverless-cloudfront-invalidate/blob/581b8f8c57e569bc4adaf0a009a1f4e4f67bbf68/index.js#L44
because autoInvalidate
is not an attribute of cloudfrontInvalidate
but is an attribute of every element of the list.
Am I wrong ?
@Ingordigia Yes, you are correct. It was broken via https://github.com/aghadiry/serverless-cloudfront-invalidate/pull/19 .
I've made a PR which should fix this https://github.com/aghadiry/serverless-cloudfront-invalidate/pull/24
@Ingordigia the PR #24 was merged and I've tested it on production Today. I found there is a small issue with it, basically, manual invalidation doesn't work anymore. Meaning if you were to invoke serverless cloudfrontInvalidate
it would skip the elements with autoInvalidate: false
. I've already submitted a fix with #25. Yikes 😬
@mihaerzen thank you for your efforts. I just tested the version 1.10.0 in my project and I can confirm that the manual invalidation doesn't work. I wait for #25 to be merged
@mihaerzen I just tested the new 1.11.0 version and it works perfectly.
I sometimes want to invalidate the cache only if the CI is deploying from the
master
branch. It would be convenient to be able to disable this plugin conditionally.I can take a stab at this :smiley: