Created
November 21, 2013 10:56
-
-
Save pataiji/7579699 to your computer and use it in GitHub Desktop.
CloudFrontのキャッシュをコマンドで簡単に削除できるとても適当なrubyファイルです。
cloudfront-invalidator に依存しているので
gem install --no-ri --no-rdoc 'cloudfront-invalidator'
でインストールして使って下さい。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# | |
# HOW TO USE: | |
# ruby invalidation.rb /index.html /test/index.html | |
# | |
# | |
gem_home = `echo $GEM_HOME` | |
gem_home = gem_home.gsub(/\n$/, '') | |
require "#{gem_home}/gems/cloudfront-invalidator-0.2.0/lib/cloudfront-invalidator.rb" | |
ACCESS_KEY_ID = 'ACCESS_KEY_ID' | |
SECRET_ACCESS_KEY = 'SECRET_ACCESS_KEY' | |
DISTRIBUTION_ID = 'DISTRIBUTION_ID' | |
def invalidation list | |
invalidator = CloudfrontInvalidator.new(ACCESS_KEY_ID, SECRET_ACCESS_KEY, DISTRIBUTION_ID) | |
if list.count > 0 | |
invalidator.invalidate(list) | |
else | |
print <<-EOF | |
キャッシュを削除したいファイルを指定して下さい | |
例: ruby invalidation /index.html /test/index.html | |
EOF | |
end | |
end | |
invalidation(ARGV) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment