Skip to content

Instantly share code, notes, and snippets.

@pataiji
Created November 21, 2013 10:56
Show Gist options
  • Save pataiji/7579699 to your computer and use it in GitHub Desktop.
Save pataiji/7579699 to your computer and use it in GitHub Desktop.
CloudFrontのキャッシュをコマンドで簡単に削除できるとても適当なrubyファイルです。 cloudfront-invalidator に依存しているので gem install --no-ri --no-rdoc 'cloudfront-invalidator' でインストールして使って下さい。
# 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