Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we have an option to conditionally disable or enable this plugin? #7

Open
forabi opened this issue Jul 16, 2018 · 7 comments
Open

Comments

@forabi
Copy link

forabi commented Jul 16, 2018

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 😃

@coyoteecd
Copy link

@aghadiry are you maintaining this project? I also need an "enabled" property; assuming I submit a pull request, will you merge and publish it?

@mihaerzen
Copy link
Contributor

I've added a PR that might help you with this. #21

With this PR you could disable the autoInvalidate and in your CI pipeline invoke the serverless cloudfrontInvalidate where required.

@Ingordigia
Copy link

Ingordigia commented Aug 24, 2021

@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

if (serverless.service.custom.cloudfrontInvalidate.autoInvalidate !== false) {

because autoInvalidate is not an attribute of cloudfrontInvalidate but is an attribute of every element of the list.

Am I wrong ?

@mihaerzen
Copy link
Contributor

@Ingordigia Yes, you are correct. It was broken via #19 .

I've made a PR which should fix this #24

@mihaerzen
Copy link
Contributor

@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 😬

@Ingordigia
Copy link

@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

@Ingordigia
Copy link

@mihaerzen
I just tested the new 1.11.0 version and it works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants