cf-s3-invalidator 0.3.9 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/cf-s3-inv CHANGED
@@ -10,6 +10,8 @@ end
10
10
  require 'optparse'
11
11
  require 'yaml'
12
12
  require 'aws-sdk'
13
+ require 'simple-cloudfront-invalidator'
14
+ require 'colored'
13
15
  require_relative '../lib/cf-s3-invalidator'
14
16
 
15
17
  class UI
@@ -136,12 +138,12 @@ module CloudfrontS3Invalidator
136
138
  class Orchestrator
137
139
  def initialize
138
140
  @options = UI.new.parse_or_print_help
139
- @cf = CloudfrontClient.new(
140
- @options[:key], @options[:secret], @options[:distribution])
141
141
  end
142
142
 
143
143
  def resolve_s3_bucket_name
144
- @s3_bucket_name = @cf.get_s3_bucket_name
144
+ cf = CloudfrontS3Invalidator::CloudfrontClient.new(
145
+ @options[:key], @options[:secret], @options[:distribution])
146
+ @s3_bucket_name = cf.get_s3_bucket_name
145
147
  if @s3_bucket_name
146
148
  puts "Resolving S3 bucket name... Got #{@s3_bucket_name.yellow}"
147
149
  else
@@ -158,7 +160,9 @@ module CloudfrontS3Invalidator
158
160
  s3_object_keys = s3.buckets[@s3_bucket_name].objects.map { |object|
159
161
  object.key
160
162
  }
161
- @cf.invalidate(s3_object_keys)
163
+ simple_cf = SimpleCloudfrontInvalidator::CloudfrontClient.new(
164
+ @options[:key], @options[:secret], @options[:distribution])
165
+ puts simple_cf.invalidate(s3_object_keys)
162
166
  end
163
167
  end
164
168
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'cf-s3-invalidator'
3
- s.version = '0.3.9'
3
+ s.version = '0.4.0'
4
4
  s.license = 'MIT'
5
5
  s.summary = 'A tool for invalidating AWS S3-based Cloudfront distributions'
6
6
  s.description =
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.homepage = 'https://github.com/laurilehmijoki/cf-s3-invalidator'
18
18
 
19
19
  s.add_dependency 'aws-sdk'
20
+ s.add_dependency 'simple-cloudfront-invalidator'
20
21
  s.add_dependency 'colored', '= 1.2'
21
22
 
22
23
  s.add_development_dependency 'cucumber'
@@ -13,26 +13,6 @@ module CloudfrontS3Invalidator
13
13
  @distribution = distribution
14
14
  end
15
15
 
16
- def invalidate(items)
17
- items = to_cf_keys(items)
18
- body = %|
19
- <InvalidationBatch>
20
- <Paths>
21
- <Quantity>#{items.length}</Quantity>
22
- <Items>
23
- #{to_xml items}
24
- </Items>
25
- </Paths>
26
- <CallerReference>#{Time.now.utc.to_i}</CallerReference>
27
- </InvalidationBatch>
28
- |
29
- res = sign_and_call(
30
- "https://cloudfront.amazonaws.com/2012-05-05/distribution/#{@distribution}/invalidation",
31
- Net::HTTP::Post,
32
- body)
33
- print_invalidation_result(res, items)
34
- end
35
-
36
16
  def get_s3_bucket_name
37
17
  res = sign_and_call(
38
18
  "https://cloudfront.amazonaws.com/2012-05-05/distribution/#{@distribution}",
@@ -71,21 +51,5 @@ module CloudfrontS3Invalidator
71
51
  raise "AWS API call failed. Reason:".red + "\n" + res.body
72
52
  end
73
53
  end
74
-
75
- def print_invalidation_result(http_response, items)
76
- puts "Invalidating Cloudfront items..."
77
- items.each do |item|
78
- puts " #{item}".yellow
79
- end
80
- puts "succeeded".green
81
- end
82
-
83
- def to_cf_keys(s3_keys)
84
- s3_keys.map { |s3_key| "/#{s3_key}" }
85
- end
86
-
87
- def to_xml(items)
88
- items.map { |item| "<Path>#{item}</Path>" }
89
- end
90
54
  end
91
55
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf-s3-invalidator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 9
10
- version: 0.3.9
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lauri Lehmijoki
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-08 00:00:00 Z
18
+ date: 2012-08-23 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: aws-sdk
@@ -32,9 +32,23 @@ dependencies:
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
35
- name: colored
35
+ name: simple-cloudfront-invalidator
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: colored
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
38
52
  none: false
39
53
  requirements:
40
54
  - - "="
@@ -45,11 +59,11 @@ dependencies:
45
59
  - 2
46
60
  version: "1.2"
47
61
  type: :runtime
48
- version_requirements: *id002
62
+ version_requirements: *id003
49
63
  - !ruby/object:Gem::Dependency
50
64
  name: cucumber
51
65
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
66
+ requirement: &id004 !ruby/object:Gem::Requirement
53
67
  none: false
54
68
  requirements:
55
69
  - - ">="
@@ -59,11 +73,11 @@ dependencies:
59
73
  - 0
60
74
  version: "0"
61
75
  type: :development
62
- version_requirements: *id003
76
+ version_requirements: *id004
63
77
  - !ruby/object:Gem::Dependency
64
78
  name: rake
65
79
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
80
+ requirement: &id005 !ruby/object:Gem::Requirement
67
81
  none: false
68
82
  requirements:
69
83
  - - ">="
@@ -73,11 +87,11 @@ dependencies:
73
87
  - 0
74
88
  version: "0"
75
89
  type: :development
76
- version_requirements: *id004
90
+ version_requirements: *id005
77
91
  - !ruby/object:Gem::Dependency
78
92
  name: aruba
79
93
  prerelease: false
80
- requirement: &id005 !ruby/object:Gem::Requirement
94
+ requirement: &id006 !ruby/object:Gem::Requirement
81
95
  none: false
82
96
  requirements:
83
97
  - - ">="
@@ -89,7 +103,7 @@ dependencies:
89
103
  - 7
90
104
  version: 0.4.7
91
105
  type: :development
92
- version_requirements: *id005
106
+ version_requirements: *id006
93
107
  description: |-
94
108
  This lib fetches the names of all objects on an Amazon Web
95
109
  Services S3 bucket. Then it calls the Cloudfront invalidation REST API on the