andrusha / middleman-cloudfront Goto Github PK
View Code? Open in Web Editor NEWAn Amazon CloudFront extension for middleman which allows you to invalidate CloudFront CDN cache
License: MIT License
An Amazon CloudFront extension for middleman which allows you to invalidate CloudFront CDN cache
License: MIT License
After merging #23 (and doing some cleanup), the master branch currently only works with Middleman v4. I would like it to work with Middleman v3 and v4 and then release 1.0. ๐
It shouldn't be too hard, we probably only need to make sure to use the v3 syntax for loading the Extension
and Invalidate
classes (see lib/middleman-bootstrap-navbar/extension.rb
here)
First I would like to add Appraisal to test different Middleman versions and started to do so in the appraisals
branch.
Since I'm no good at Cucumber, I'm having a hard time writing the cukes though. ๐
If someone could help me out here, that would be fantastic.
@andrusha do you have time?
When I run invalidate after build, I get the following error message:
## Invalidating files on CloudFront
Invalidating 6 files. It might take 10 to 15 minutes until all files are invalidated.
Please check the AWS Management Console to see the status of the invalidation.
/Users/juanjo/.rvm/gems/ruby-2.1.2/gems/middleman-cloudfront-0.1.0/lib/middleman-cloudfront/commands.rb:64:in `invalidate': undefined method `invalidations' for nil:NilClass (NoMethodError)
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/middleman-core-3.3.7/lib/middleman-core/cli.rb:72:in `method_missing'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/command.rb:29:in `run'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/command.rb:126:in `run'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/middleman-core-3.3.7/lib/middleman-core/cli.rb:20:in `start'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/gems/middleman-core-3.3.7/bin/middleman:18:in `<top (required)>'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/bin/middleman:23:in `load'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/bin/middleman:23:in `<main>'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
from /Users/juanjo/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
I am using:
middleman-3.3.7
middleman-cloudfront-0.1.0
middleman-s3_sync-3.0.35
And this is an excerpt of my config.rb:
aws_config = YAML::load(File.open('aws.yml'))
activate :s3_sync do |s3_sync|
s3_sync.bucket = aws_config['s3_bucket']
s3_sync.region = aws_config['aws_region']
s3_sync.aws_access_key_id = aws_config['access_key_id']
s3_sync.aws_secret_access_key = aws_config['secret_access_key']
s3_sync.delete = true
s3_sync.after_build = true
end
activate :cloudfront do |cf|
cf.access_key_id = aws_config['access_key_id']
cf.secret_access_key = aws_config['secret_access_key']
cf.distribution_id = aws_config['cloud_front_dist_id']
cf.filter = /\.html$/i
cf.after_build = false
end
I got an email from Amazon:
Amazon CloudFront's invalidation feature, which allows you to remove an object from the CloudFront cache before it expires, now supports the * wildcard character. You can add a * wildcard character at the end of an invalidation path to remove all objects that match this path. In the past, when you wanted to invalidate multiple objects, you had to list every object path separately. Now, you can easily invalidate multiple objects using the * wildcard character.
Using the * wildcard character in the invalidation path is useful for many use cases. For example, if you're doing a new deployment, you can now just use /* to invalidate the entire distribution. Similarly, if you want to invalidate all objects for a specific end user, you can invalidate the content in a directory, for example, /enduser-x-data/*.
This new capability can also help you lower your cost of invalidating multiple objects. Invalidation paths that include the * wildcard (representing multiple objects) incur the same charge as an invalidation path that represents a single object. As before, the first 1,000 invalidation paths each month are provided at no additional charge and above this level, there is a $0.005 charge per invalidation path. But now you pay $0.005 for the /directory-name/* invalidation path even if this path matches thousands of objects. For more information on invalidation pricing, see Amazon CloudFront Pricing.
Maybe we should rework this to make sure we can invalidate with a wildcard (e.g. after an s3 sync?). I haven't tested this yet, though.
Fetching gem metadata from http://rubygems.org/..
Bundler could not find compatible versions for gem "listen":
In Gemfile:
middleman-cloudfront (>= 0) ruby depends on
listen (~> 0.4.7) ruby
guard-livereload (>= 0) ruby depends on
listen (0.7.2)
My ruby version: ruby-1.9.3-p362
Middleman is currently on its way to release verison 4.0. Unfortunately, middleman-cloudfront still has a dependency which restricts versions > 3.
You can find recent middleman alpha releases here: https://rubygems.org/gems/middleman-core (4.0.0.alpha.6 is the most recent one as of this writing)
I would really appreciate it, if this very helpful gem would introduce support for version 4.0
When I run invalidate after build, I get the following error message
## Invalidating files on CloudFront
== Unknown Extension: livereload
== Locales: de (Default de)
== Unknown Extension: livereload
== Locales: de (Default de)
== Unknown Extension: livereload
== Locales: de (Default de)
== Unknown Extension: livereload
== Locales: de (Default de)
x Invalidating 252 files. It might take 10 to 15 minutes until all files are invalidated.
Please check the AWS Management Console to see the status of the invalidation.
livereload
is unknown, as I have it in the development
group of my Gemfile
.
At least when I run invalidate with middleman build
it should respect the :build
block and ignore the :development
block.
Second, I wonder why it tries to load the configuration four times.
An excerpt of my config.rb
if ENV['AWS_ACCESS_KEY_ID'] && ENV['AWS_SECRET_ACCESS_KEY'] && ENV['AWS_CF_DISTRIBUTION_ID']
activate :cloudfront do |cf|
cf.access_key_id = ENV['AWS_ACCESS_KEY_ID']
cf.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
cf.distribution_id = ENV['AWS_CF_DISTRIBUTION_ID']
cf.after_build = true
end
end
configure :development do
# Reload the browser automatically whenever files change
activate :livereload,
no_swf: true
config[:file_watcher_ignore] += [%r{\.idea/}]
activate :google_analytics do |ga|
ga.tracking_id = false
end
end
# Build-specific configuration
configure :build do
# ...
end
It would be great if I could call bundle exec middleman invalidate --dry-run
which would then just output list_files(options.filter)
(see commands.rb#L58).
This would allow me to see if my filter regex is correct or if I did some mistake
I've been running across this error since upgrading to cloud front 0.1.1, was hoping someone might have insight into the error. Thanks!
middleman-cloudfront/commands.rb:70:in
invalidate': undefined method invalidations' for nil:NilClass (NoMethodError)
When I try to invalidate, I always get a timeout after a while:
11:36:21 ~/code/myapp (master) $ bundle exec middleman invalidate
## Invalidating files on CloudFront
Please wait while Cloudfront is reloading 15 paths, it might take up to 10 minutes
/Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/fog-1.11.1/lib/fog/core/wait_for.rb:10:in `wait_for': The specified wait_for timeout (600 seconds) was exceeded (Fog::Errors::TimeoutError)
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/fog-1.11.1/lib/fog/core/model.rb:64:in `wait_for'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/middleman-cloudfront-0.0.5/lib/middleman-cloudfront/commands.rb:34:in `block in invalidate'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/middleman-cloudfront-0.0.5/lib/middleman-cloudfront/commands.rb:31:in `each_slice'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/middleman-cloudfront-0.0.5/lib/middleman-cloudfront/commands.rb:31:in `invalidate'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/thor-0.15.4/lib/thor/task.rb:27:in `run'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/thor-0.15.4/lib/thor/invocation.rb:120:in `invoke_task'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/thor-0.15.4/lib/thor.rb:275:in `dispatch'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/thor-0.15.4/lib/thor/base.rb:425:in `start'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/middleman-core-3.1.0.rc.1/lib/middleman-core/cli.rb:77:in `method_missing'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/thor-0.15.4/lib/thor/task.rb:29:in `run'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/thor-0.15.4/lib/thor/task.rb:126:in `run'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/thor-0.15.4/lib/thor/invocation.rb:120:in `invoke_task'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/thor-0.15.4/lib/thor.rb:275:in `dispatch'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/thor-0.15.4/lib/thor/base.rb:425:in `start'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/middleman-core-3.1.0.rc.1/lib/middleman-core/cli.rb:22:in `start'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/middleman-core-3.1.0.rc.1/bin/middleman:18:in `<top (required)>'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/bin/middleman:23:in `load'
from /Users/manuel/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/bin/middleman:23:in `<main>'
When I check the AWS console, I see that the invalidation is there, it's "InProgress", and it's invalidating the correct paths.
Would you be open to adding an option that lets Middleman::Cli::CloudFront#invalidate
return immediately, reporting the invalidation status, instead of waiting for ready?
?
middleman build
logs the following
identical build/opensearch.xml
update build/blog/2013/04/01/index.html
update build/blog/2013/03/index.html
update build/impressum/index.html
It would be great, if middleman-cloudfront would only invalidate the files market with update
Despite the correct gemspec for 0.2.1 here on Github, the 0.2.1 on rubygems.org is still stuck at middleman-core ~> 3.0
for some reason. I'm not sure how that might have happened, as you commit history seems to indicate you update the dependency before bumping the version!
In any case, it's breaking Bundler for automatic installs. You might want to bump the version and release it again.
I'll do a local install from this repo for the time being.
If the AWS gem was used it would automatically pick up credentials via IAM roles as well as ENV and a file in ~/.aws/โฆ
. I also find it more stable than Fog and with fewer dependencies. Have you considered replacing fog?
Fetching gem metadata from http://rubygems.org/..
Bundler could not find compatible versions for gem "fog":
In Gemfile:
middleman-cloudfront (>= 0) ruby depends on
fog (~> 1.9.0) ruby
middleman-sync (~> 3.0.9) ruby depends on
fog (1.10.1)
Hey @andrusha ! Thanks for the gem! First time using it and looks awesome, although I ran into this issue. Could you pls update the dependencies? Thanks a lot!
Bundler could not find compatible versions for gem "middleman-core":
In snapshot (Gemfile.lock):
middleman-core (= 4.1.9)
In Gemfile:
middleman (>= 4.0.0) was resolved to 4.1.9, which depends on
middleman-core (= 4.1.9)
middleman-cloudfront (~> 0.2.1) was resolved to 0.2.1, which depends on
middleman-core (~> 3.0)
.......
rubygems.org does not have the latest version of this repo despite an update to the gemspec. Please update.
Title says it all! :)
https://groups.google.com/forum/#!msg/nokogiri-talk/dt6baTiT4Zw/FiWr9B0Pb9kJ
Here is how Fog handles it: https://github.com/fog/fog/pull/1905/files
Since Ruby 1.8.7 is officially retired now, the other option would be to require Ruby >= 1.9.2 and drop support for 1.8.7 as well.
http://www.ruby-lang.org/en/news/2013/06/30/we-retire-1-8-7/
Hi,
when running middleman help
inside the the project with this gem installed, the command for invalidation is shown as middleman cloudfront:invalidate
while the actual command that works is middleman invalidate
which was confusing to me.
I think this is because of line 21 in this file https://github.com/andrusha/middleman-cloudfront/blob/master/lib/middleman-cloudfront/commands.rb .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.