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 cloudfront task invalidation array be dynamic? #23

Open
kaffolder7 opened this issue Jan 27, 2015 · 4 comments
Open

Can cloudfront task invalidation array be dynamic? #23

kaffolder7 opened this issue Jan 27, 2015 · 4 comments

Comments

@kaffolder7
Copy link

I absolutely LOVE this grunt plugin, but am really having a hard time using the cloudfront task. It appears from the documentation that the 'invalidations' array needs to have static full paths to files passed in (i.e. '/index.html', '/assets/css/main.css', etc.). However, as I'm sure you can deduce, keeping a list of every file in the project (esp. as the project grows over time) with each file being it's own line-item/string is exhaustive. I was hoping that instead, I could use some of Grunt's built-in globbing functions so that I am able to scan the entire folder tree for specific file types and invalidate those files.

Here's what I'm trying below in my Gruntfile. If anyone has any ideas, please let me know! This causes the Grunt build to fail. Not sure why I cannot use Grunt's globbing patterns. :(

cloudfront: {
    options: {
        accessKeyId: '###masked for security###',  // confirmed this is working
        secretAccessKey: '###masked for security###',  // confirmed this is working
        distributionId: '###masked for security###',  // confirmed this is working
        invalidations: [
            // Fonts
            '/assets/fonts/**/*.{eot,svg,ttf,woff,woff2}',
            // Text
            '/**/*.{txt,xml,pdf}',
            // Images
            '/assets/images/**/*.{jpg,webp,png,gif}',
            '/projects/images/**/*.{jpg,webp,png,gif}',
            // JS
            '/assets/js/**/*.{js,map}',
            // CSS
            '/assets/css/**/*.{css,map}',
            // HTML
            '/**/*.html'
        ]
    }
}
@jpillora
Copy link
Owner

I'm guessing globbing patterns support needs to be added, I don't actually use cloud front, @bxjx any ideas?

@treasonx
Copy link

Yeah I would love to be able to tell which assets were synced with the s3 task and invalidate those items. Or at the very least use the file list from the s3 sync as the invalidation list.

@kaffolder7
Copy link
Author

Any updates here anyone, or have either of you @jpillora / @treasonx figured out a viable solution that you're using until this type of globbing pattern support is added?

@lukebussey
Copy link
Contributor

Invalidation paths can now be dynamic, so you can just do this:

options: {
    invalidations: ['/assets/fonts/*']
}

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

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

No branches or pull requests

4 participants