right_aws 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +22 -1
- data/Manifest.txt +11 -1
- data/README.txt +0 -4
- data/Rakefile +19 -25
- data/lib/acf/right_acf_interface.rb +199 -135
- data/lib/acf/right_acf_invalidations.rb +144 -0
- data/lib/acf/right_acf_origin_access_identities.rb +4 -4
- data/lib/acf/right_acf_streaming_interface.rb +19 -26
- data/lib/acw/right_acw_interface.rb +1 -2
- data/lib/as/right_as_interface.rb +6 -7
- data/lib/awsbase/right_awsbase.rb +287 -91
- data/lib/awsbase/support.rb +2 -82
- data/lib/awsbase/version.rb +9 -0
- data/lib/ec2/right_ec2.rb +101 -38
- data/lib/ec2/right_ec2_ebs.rb +71 -58
- data/lib/ec2/right_ec2_images.rb +82 -42
- data/lib/ec2/right_ec2_instances.rb +74 -44
- data/lib/ec2/right_ec2_placement_groups.rb +108 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +50 -46
- data/lib/ec2/right_ec2_security_groups.rb +148 -32
- data/lib/ec2/right_ec2_spot_instances.rb +53 -27
- data/lib/ec2/right_ec2_tags.rb +139 -0
- data/lib/ec2/right_ec2_vpc.rb +151 -139
- data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
- data/lib/elb/right_elb_interface.rb +93 -18
- data/lib/iam/right_iam_access_keys.rb +71 -0
- data/lib/iam/right_iam_groups.rb +195 -0
- data/lib/iam/right_iam_interface.rb +341 -0
- data/lib/iam/right_iam_mfa_devices.rb +67 -0
- data/lib/iam/right_iam_users.rb +251 -0
- data/lib/rds/right_rds_interface.rb +513 -202
- data/lib/right_aws.rb +12 -12
- data/lib/route_53/right_route_53_interface.rb +630 -0
- data/lib/s3/right_s3.rb +9 -12
- data/lib/s3/right_s3_interface.rb +10 -11
- data/lib/sdb/active_sdb.rb +18 -33
- data/lib/sdb/right_sdb_interface.rb +36 -4
- data/lib/sqs/right_sqs.rb +1 -2
- data/lib/sqs/right_sqs_gen2.rb +0 -1
- data/lib/sqs/right_sqs_gen2_interface.rb +4 -5
- data/lib/sqs/right_sqs_interface.rb +6 -7
- data/right_aws.gemspec +91 -0
- data/test/awsbase/test_helper.rb +2 -0
- data/test/awsbase/test_right_awsbase.rb +12 -0
- data/test/s3/test_right_s3.rb +1 -1
- data/test/sdb/test_active_sdb.rb +1 -1
- data/test/sdb/test_batch_put_attributes.rb +54 -0
- data/test/sqs/test_right_sqs.rb +0 -6
- data/test/sqs/test_right_sqs_gen2.rb +1 -1
- metadata +109 -58
data/History.txt
CHANGED
@@ -281,4 +281,25 @@ the source key.
|
|
281
281
|
RightAws::Ec2#create_snapshot,
|
282
282
|
RightAws::Ec2#try_create_snapshot
|
283
283
|
- :created_time in:
|
284
|
-
RightAws::ElbInterface#describe_load_balancers
|
284
|
+
RightAws::ElbInterface#describe_load_balancers
|
285
|
+
|
286
|
+
=== 2.1.0
|
287
|
+
Release Notes:
|
288
|
+
- Added:
|
289
|
+
- Route 53: API '2010-10-01'
|
290
|
+
- ACF: API '2010-11-01'
|
291
|
+
- EC2:
|
292
|
+
- API '2010-08-31'
|
293
|
+
- Port based group permissions support
|
294
|
+
- HPC Support
|
295
|
+
- Tags Suport
|
296
|
+
- ClientToken support added on instance launch
|
297
|
+
- RDS: API "2010-07-28"
|
298
|
+
- ELB: API '2010-07-01' (SSL support)
|
299
|
+
- IAM: API '2010-05-08' (AWS Identity and Access Management interface)
|
300
|
+
- 301 Redirect support added
|
301
|
+
- Removed:
|
302
|
+
- ActiveSupport dependency
|
303
|
+
- SDB: uuid gem dependency
|
304
|
+
- this gem requires right_http_connection 0bc3343232133bdb38c237d8285525d74495d3f5 or later
|
305
|
+
- "Raise On Timeout On Action" feature added to avoid duplicate resources creation if a timeout error occures and a retry is performed
|
data/Manifest.txt
CHANGED
@@ -2,9 +2,9 @@ History.txt
|
|
2
2
|
Manifest.txt
|
3
3
|
README.txt
|
4
4
|
Rakefile
|
5
|
+
lib/awsbase/support.rb
|
5
6
|
lib/awsbase/benchmark_fix.rb
|
6
7
|
lib/awsbase/right_awsbase.rb
|
7
|
-
lib/awsbase/support.rb
|
8
8
|
lib/ec2/right_ec2.rb
|
9
9
|
lib/ec2/right_ec2_images.rb
|
10
10
|
lib/ec2/right_ec2_instances.rb
|
@@ -14,6 +14,9 @@ lib/ec2/right_ec2_ebs.rb
|
|
14
14
|
lib/ec2/right_ec2_reserved_instances.rb
|
15
15
|
lib/ec2/right_ec2_vpc.rb
|
16
16
|
lib/ec2/right_ec2_monitoring.rb
|
17
|
+
lib/ec2/right_ec2_placement_groups.rb
|
18
|
+
lib/ec2/right_ec2_windows_mobility.rb
|
19
|
+
lib/ec2/right_ec2_tags.rb
|
17
20
|
lib/right_aws.rb
|
18
21
|
lib/s3/right_s3.rb
|
19
22
|
lib/acw/right_acw_interface.rb
|
@@ -29,7 +32,14 @@ lib/sqs/right_sqs_interface.rb
|
|
29
32
|
lib/acf/right_acf_interface.rb
|
30
33
|
lib/acf/right_acf_streaming_interface.rb
|
31
34
|
lib/acf/right_acf_origin_access_identities.rb
|
35
|
+
lib/acf/right_acf_invalidations.rb
|
32
36
|
lib/rds/right_rds_interface.rb
|
37
|
+
lib/iam/right_iam_interface.rb
|
38
|
+
lib/iam/right_iam_groups.rb
|
39
|
+
lib/iam/right_iam_users.rb
|
40
|
+
lib/iam/right_iam_access_keys.rb
|
41
|
+
lib/iam/right_iam_mfa_devices.rb
|
42
|
+
lib/route_53/right_route_53_interface.rb
|
33
43
|
test/ec2/test_helper.rb
|
34
44
|
test/ec2/test_right_ec2.rb
|
35
45
|
test/http_connection.rb
|
data/README.txt
CHANGED
@@ -68,10 +68,6 @@ concurrent requests to AWS. The way this plays out in practice is:
|
|
68
68
|
Note that due to limitations in the I/O of the Ruby interpreter you
|
69
69
|
may not get the degree of parallelism you may expect with the multi-threaded setting.
|
70
70
|
|
71
|
-
By default, EC2/S3/SQS/SDB/ACF interface instances are created in single-threaded mode. Set
|
72
|
-
"params[:multi_thread]" to "true" in the initialization arguments to use
|
73
|
-
multithreaded mode.
|
74
|
-
|
75
71
|
== GETTING STARTED:
|
76
72
|
|
77
73
|
* For EC2 read RightAws::Ec2 and consult the Amazon EC2 API documentation at
|
data/Rakefile
CHANGED
@@ -1,45 +1,39 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require 'hoe'
|
5
4
|
require "rake/testtask"
|
6
5
|
require 'rcov/rcovtask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/clean'
|
7
8
|
$: << File.dirname(__FILE__)
|
8
|
-
require 'lib/right_aws.rb'
|
9
|
-
|
10
9
|
testglobs = ["test/ts_right_aws.rb"]
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@extra_deps.reject do |x|
|
19
|
-
Array(x).first == 'hoe'
|
20
|
-
end
|
21
|
-
end
|
11
|
+
begin
|
12
|
+
require 'bundler'
|
13
|
+
rescue LoadError => e
|
14
|
+
STDERR.puts("Bundler is not available, some rake tasks will not be defined: #{e.message}")
|
15
|
+
else
|
16
|
+
Bundler::GemHelper.install_tasks
|
22
17
|
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
31
|
-
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
32
|
-
p.remote_rdoc_dir = "/right_aws_gem_doc"
|
33
|
-
p.extra_deps = [['right_http_connection','>= 1.2.1']]
|
34
|
-
p.test_globs = testglobs
|
19
|
+
# == Gem == #
|
20
|
+
|
21
|
+
gemtask = Rake::GemPackageTask.new(Gem::Specification.load("right_aws.gemspec")) do |package|
|
22
|
+
package.package_dir = ENV['PACKAGE_DIR'] || 'pkg'
|
23
|
+
package.need_zip = true
|
24
|
+
package.need_tar = true
|
35
25
|
end
|
36
26
|
|
27
|
+
directory gemtask.package_dir
|
28
|
+
|
29
|
+
CLEAN.include(gemtask.package_dir)
|
30
|
+
|
37
31
|
desc "Analyze code coverage of the unit tests."
|
38
32
|
Rcov::RcovTask.new do |t|
|
39
33
|
t.test_files = FileList[testglobs]
|
40
34
|
#t.verbose = true # uncomment to see the executed command
|
41
35
|
end
|
42
|
-
|
36
|
+
|
43
37
|
desc "Test just the SQS interface"
|
44
38
|
task :testsqs do
|
45
39
|
require 'test/test_credentials'
|
@@ -38,7 +38,7 @@ module RightAws
|
|
38
38
|
# [{:status => "Deployed",
|
39
39
|
# :domain_name => "d74zzrxmpmygb.6hops.net",
|
40
40
|
# :aws_id => "E4U91HCJHGXVC",
|
41
|
-
# :
|
41
|
+
# :s3_origin => {:dns_name=>"bucket-for-konstantin-00.s3.amazonaws.com"},
|
42
42
|
# :cnames => ["x1.my-awesome-site.net", "x1.my-awesome-site.net"]
|
43
43
|
# :comment => "My comments",
|
44
44
|
# :last_modified_time => "2008-09-10T17:00:04.000Z" }, ..., {...} ]
|
@@ -46,16 +46,17 @@ module RightAws
|
|
46
46
|
# distibution = list.first
|
47
47
|
#
|
48
48
|
# info = acf.get_distribution(distibution[:aws_id]) #=>
|
49
|
-
# {:
|
50
|
-
# :
|
51
|
-
# :
|
52
|
-
# :
|
53
|
-
# :
|
54
|
-
# :
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
# :
|
49
|
+
# {:last_modified_time=>"2010-05-19T18:54:38.242Z",
|
50
|
+
# :status=>"Deployed",
|
51
|
+
# :domain_name=>"dpzl38cuix402.cloudfront.net",
|
52
|
+
# :caller_reference=>"201005181943052207677116",
|
53
|
+
# :e_tag=>"EJSXFGM5JL8ER",
|
54
|
+
# :s3_origin=>
|
55
|
+
# {:dns_name=>"bucket-for-konstantin-eu.s3.amazonaws.com",
|
56
|
+
# :origin_access_identity=>
|
57
|
+
# "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
|
58
|
+
# :aws_id=>"E5P8HQ3ZAZIXD",
|
59
|
+
# :enabled=>false}
|
59
60
|
#
|
60
61
|
# config = acf.get_distribution_config(distibution[:aws_id]) #=>
|
61
62
|
# {:enabled => true,
|
@@ -63,7 +64,7 @@ module RightAws
|
|
63
64
|
# :e_tag => "E39OHHU1ON65SI",
|
64
65
|
# :cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
|
65
66
|
# :comment => "Woo-Hoo!",
|
66
|
-
# :
|
67
|
+
# :s3_origin => {:dns_name => "my-bucket.s3.amazonaws.com"}}
|
67
68
|
#
|
68
69
|
# config[:comment] = 'Olah-lah!'
|
69
70
|
# config[:enabled] = false
|
@@ -75,7 +76,7 @@ module RightAws
|
|
75
76
|
|
76
77
|
include RightAwsBaseInterface
|
77
78
|
|
78
|
-
API_VERSION = "2010-
|
79
|
+
API_VERSION = "2010-11-01"
|
79
80
|
DEFAULT_HOST = 'cloudfront.amazonaws.com'
|
80
81
|
DEFAULT_PORT = 443
|
81
82
|
DEFAULT_PROTOCOL = 'https'
|
@@ -96,7 +97,6 @@ module RightAws
|
|
96
97
|
# * <tt>:server</tt>: CloudFront service host, default: DEFAULT_HOST
|
97
98
|
# * <tt>:port</tt>: CloudFront service port, default: DEFAULT_PORT
|
98
99
|
# * <tt>:protocol</tt>: 'http' or 'https', default: DEFAULT_PROTOCOL
|
99
|
-
# * <tt>:multi_thread</tt>: true=HTTP connection per thread, false=per process
|
100
100
|
# * <tt>:logger</tt>: for log messages, default: RAILS_DEFAULT_LOGGER else STDOUT
|
101
101
|
#
|
102
102
|
# acf = RightAws::AcfInterface.new('1E3GDYEOGFJPIT7XXXXXX','hgTHt68JY07JKUY08ftHYtERkjgtfERn57XXXXXX',
|
@@ -121,8 +121,8 @@ module RightAws
|
|
121
121
|
# Generates request hash for REST API.
|
122
122
|
def generate_request(method, path, params={}, body=nil, headers={}) # :nodoc:
|
123
123
|
# Params
|
124
|
-
params.delete_if{ |key, val| val.
|
125
|
-
unless params.
|
124
|
+
params.delete_if{ |key, val| val.right_blank? }
|
125
|
+
unless params.right_blank?
|
126
126
|
path += "?" + params.to_a.collect{ |key,val| "#{AwsUtils::amz_escape(key)}=#{AwsUtils::amz_escape(val.to_s)}" }.join("&")
|
127
127
|
end
|
128
128
|
# Headers
|
@@ -133,7 +133,7 @@ module RightAws
|
|
133
133
|
headers['Authorization'] = "AWS #{@aws_access_key_id}:#{signature}"
|
134
134
|
# Request
|
135
135
|
path = "#{@params[:service]}#{@params[:api_version]}/#{path}"
|
136
|
-
request = "Net::HTTP::#{method.capitalize}".
|
136
|
+
request = "Net::HTTP::#{method.capitalize}".right_constantize.new(path)
|
137
137
|
request.body = body if body
|
138
138
|
# Set request headers
|
139
139
|
headers.each { |key, value| request[key.to_s] = value }
|
@@ -154,14 +154,6 @@ module RightAws
|
|
154
154
|
# Helpers:
|
155
155
|
#-----------------------------------------------------------------
|
156
156
|
|
157
|
-
def self.escape(text) # :nodoc:
|
158
|
-
REXML::Text::normalize(text)
|
159
|
-
end
|
160
|
-
|
161
|
-
def self.unescape(text) # :nodoc:
|
162
|
-
REXML::Text::unnormalize(text)
|
163
|
-
end
|
164
|
-
|
165
157
|
def generate_call_reference # :nodoc:
|
166
158
|
result = Time.now.strftime('%Y%m%d%H%M%S')
|
167
159
|
10.times{ result << rand(10).to_s }
|
@@ -175,31 +167,30 @@ module RightAws
|
|
175
167
|
end
|
176
168
|
|
177
169
|
def distribution_config_to_xml(config, xml_wrapper='DistributionConfig') # :nodoc:
|
178
|
-
cnames = ''
|
179
|
-
logging = ''
|
180
|
-
origin_access_identity = ''
|
181
|
-
trusted_signers = ''
|
170
|
+
cnames = logging = trusted_signers = s3_origin = custom_origin = default_root_object = ''
|
182
171
|
# CNAMES
|
183
|
-
unless config[:cnames].
|
172
|
+
unless config[:cnames].right_blank?
|
184
173
|
Array(config[:cnames]).each { |cname| cnames += " <CNAME>#{cname}</CNAME>\n" }
|
185
174
|
end
|
186
175
|
# Logging
|
187
|
-
unless config[:logging].
|
176
|
+
unless config[:logging].right_blank?
|
188
177
|
logging = " <Logging>\n" +
|
189
178
|
" <Bucket>#{config[:logging][:bucket]}</Bucket>\n" +
|
190
179
|
" <Prefix>#{config[:logging][:prefix]}</Prefix>\n" +
|
191
180
|
" </Logging>\n"
|
192
181
|
end
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
182
|
+
unless config[:required_protocols].right_blank?
|
183
|
+
required_protocols = " <RequiredProtocols>\n" +
|
184
|
+
" <Protocol>#{config[:required_protocols]}</Protocol>\n" +
|
185
|
+
" </RequiredProtocols>\n"
|
186
|
+
else required_protocols = ""
|
187
|
+
end
|
188
|
+
# Default Root Object
|
189
|
+
unless config[:default_root_object].right_blank?
|
190
|
+
default_root_object = " <DefaultRootObject>#{config[:default_root_object]}</DefaultRootObject>\n" unless config[:default_root_object].right_blank?
|
200
191
|
end
|
201
192
|
# Trusted Signers
|
202
|
-
unless config[:trusted_signers].
|
193
|
+
unless config[:trusted_signers].right_blank?
|
203
194
|
trusted_signers = " <TrustedSigners>\n"
|
204
195
|
Array(config[:trusted_signers]).each do |trusted_signer|
|
205
196
|
trusted_signers += if trusted_signer.to_s[/self/i]
|
@@ -210,18 +201,48 @@ module RightAws
|
|
210
201
|
end
|
211
202
|
trusted_signers += " </TrustedSigners>\n"
|
212
203
|
end
|
213
|
-
|
204
|
+
# S3Origin
|
205
|
+
unless config[:s3_origin].right_blank?
|
206
|
+
origin_access_identity = ''
|
207
|
+
# Origin Access Identity
|
208
|
+
unless config[:s3_origin][:origin_access_identity].right_blank?
|
209
|
+
origin_access_identity = config[:s3_origin][:origin_access_identity]
|
210
|
+
unless origin_access_identity[%r{^origin-access-identity}]
|
211
|
+
origin_access_identity = "origin-access-identity/cloudfront/#{origin_access_identity}"
|
212
|
+
end
|
213
|
+
origin_access_identity = " <OriginAccessIdentity>#{origin_access_identity}</OriginAccessIdentity>\n"
|
214
|
+
end
|
215
|
+
s3_origin = " <S3Origin>\n" +
|
216
|
+
" <DNSName>#{config[:s3_origin][:dns_name]}</DNSName>\n" +
|
217
|
+
"#{origin_access_identity}" +
|
218
|
+
" </S3Origin>\n"
|
219
|
+
end
|
220
|
+
# Custom Origin
|
221
|
+
unless config[:custom_origin].right_blank?
|
222
|
+
http_port = https_port = origin_protocol_policy = ''
|
223
|
+
http_port = " <HTTPPort>#{config[:custom_origin][:http_port]}</HTTPPort>\n" unless config[:custom_origin][:http_port].right_blank?
|
224
|
+
https_port = " <HTTPSPort>#{config[:custom_origin][:https_port]}</HTTPSPort>" unless config[:custom_origin][:https_port].right_blank?
|
225
|
+
origin_protocol_policy = " <OriginProtocolPolicy>#{config[:custom_origin][:origin_protocol_policy]}</OriginProtocolPolicy>\n" unless config[:custom_origin][:origin_protocol_policy].right_blank?
|
226
|
+
custom_origin = " <CustomOrigin>\n" +
|
227
|
+
" <DNSName>#{config[:custom_origin][:dns_name]}</DNSName>\n" +
|
228
|
+
"#{http_port}" +
|
229
|
+
"#{https_port}" +
|
230
|
+
"#{origin_protocol_policy}" +
|
231
|
+
" </CustomOrigin>\n"
|
232
|
+
end
|
214
233
|
# XML
|
215
|
-
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
234
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
216
235
|
"<#{xml_wrapper} xmlns=\"http://#{@params[:server]}/doc/#{API_VERSION}/\">\n" +
|
217
|
-
" <
|
218
|
-
" <
|
219
|
-
" <Comment>#{AcfInterface::escape(config[:comment].to_s)}</Comment>\n" +
|
236
|
+
" <CallerReference>#{config[:caller_reference]}</CallerReference>\n" +
|
237
|
+
" <Comment>#{AwsUtils::xml_escape(config[:comment].to_s)}</Comment>\n" +
|
220
238
|
" <Enabled>#{config[:enabled]}</Enabled>\n" +
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
239
|
+
s3_origin +
|
240
|
+
custom_origin +
|
241
|
+
default_root_object +
|
242
|
+
cnames +
|
243
|
+
logging +
|
244
|
+
required_protocols +
|
245
|
+
trusted_signers +
|
225
246
|
"</#{xml_wrapper}>"
|
226
247
|
end
|
227
248
|
|
@@ -233,13 +254,13 @@ module RightAws
|
|
233
254
|
# Returns an array of distributions or RightAws::AwsError exception.
|
234
255
|
#
|
235
256
|
# acf.list_distributions #=>
|
236
|
-
# [{:status
|
237
|
-
# :domain_name
|
238
|
-
# :
|
239
|
-
# :
|
240
|
-
# :
|
241
|
-
# :
|
242
|
-
# :
|
257
|
+
# [{:status=>"Deployed",
|
258
|
+
# :domain_name=>"dgmde.6os.net",
|
259
|
+
# :comment=>"ONE LINE OF COMMENT",
|
260
|
+
# :last_modified_time=>"2009-06-16T16:10:02.210Z",
|
261
|
+
# :s3_origin=>{:dns_name=>"example.s3.amazonaws.com"},
|
262
|
+
# :aws_id=>"12Q05OOMFN7SYL",
|
263
|
+
# :enabled=>true}, ... ]
|
243
264
|
#
|
244
265
|
def list_distributions
|
245
266
|
result = []
|
@@ -259,7 +280,7 @@ module RightAws
|
|
259
280
|
# {:distributions=>
|
260
281
|
# [{:status=>"Deployed",
|
261
282
|
# :aws_id=>"E2Q0AOOMFNPSYL",
|
262
|
-
# :
|
283
|
+
# :s3_origin=>{:dns_name=>"example.s3.amazonaws.com"},
|
263
284
|
# :domain_name=>"d1s5gmdtmafnre.6hops.net",
|
264
285
|
# :comment=>"ONE LINE OF COMMENT",
|
265
286
|
# :last_modified_time=>"2008-10-22T19:31:23.000Z",
|
@@ -288,7 +309,7 @@ module RightAws
|
|
288
309
|
link = generate_request('GET', 'distribution', opts)
|
289
310
|
last_response = request_info(link, AcfDistributionListParser.new(:logger => @logger))
|
290
311
|
opts['Marker'] = last_response[:next_marker]
|
291
|
-
break unless block && block.call(last_response) && !last_response[:next_marker].
|
312
|
+
break unless block && block.call(last_response) && !last_response[:next_marker].right_blank?
|
292
313
|
end
|
293
314
|
last_response
|
294
315
|
end
|
@@ -296,51 +317,80 @@ module RightAws
|
|
296
317
|
# Create a new distribution.
|
297
318
|
# Returns the just created distribution or RightAws::AwsError exception.
|
298
319
|
#
|
299
|
-
#
|
300
|
-
# { :prefix=>"log/", :bucket=>"my-logs.s3.amazonaws.com" } ) #=>
|
301
|
-
# {:comment => "Woo-Hoo!",
|
302
|
-
# :enabled => true,
|
303
|
-
# :location => "https://cloudfront.amazonaws.com/2008-06-30/distribution/E2REJM3VUN5RSI",
|
304
|
-
# :status => "InProgress",
|
305
|
-
# :aws_id => "E2REJM3VUN5RSI",
|
306
|
-
# :domain_name => "d3dxv71tbbt6cd.6hops.net",
|
307
|
-
# :origin => "my-bucket.s3.amazonaws.com",
|
308
|
-
# :cnames => ["web1.my-awesome-site.net"],
|
309
|
-
# :logging => { :prefix => "log/",
|
310
|
-
# :bucket => "my-logs.s3.amazonaws.com"},
|
311
|
-
# :last_modified_time => "2008-10-22T19:31:23.000Z",
|
312
|
-
# :caller_reference => "200809102100536497863003"}
|
320
|
+
# # S3 Origin
|
313
321
|
#
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
322
|
+
# config = { :comment => "kd: delete me please",
|
323
|
+
# :s3_origin => { :dns_name => "devs-us-east.s3.amazonaws.com",
|
324
|
+
# :origin_access_identity => "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
|
325
|
+
# :enabled => true,
|
326
|
+
# :logging => { :prefix => "kd/log/",
|
327
|
+
# :bucket => "devs-us-west.s3.amazonaws.com"}}
|
328
|
+
# acf.create_distribution(config) #=>
|
329
|
+
# { :status=>"InProgress",
|
330
|
+
# :enabled=>true,
|
331
|
+
# :caller_reference=>"201012071910051044304704",
|
332
|
+
# :logging=>{:prefix=>"kd/log/", :bucket=>"devs-us-west.s3.amazonaws.com"},
|
333
|
+
# :e_tag=>"ESCTG5WJCFWJK",
|
334
|
+
# :location=> "https://cloudfront.amazonaws.com/2010-11-01/distribution/E3KUBANZ7N1B2",
|
335
|
+
# :comment=>"kd: delete me please",
|
336
|
+
# :domain_name=>"d3stykk6upgs20.cloudfront.net",
|
337
|
+
# :aws_id=>"E3KUBANZ7N1B2",
|
338
|
+
# :s3_origin=>
|
339
|
+
# {:origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
|
340
|
+
# :dns_name=>"devs-us-east.s3.amazonaws.com"},
|
341
|
+
# :last_modified_time=>"2010-12-07T16:10:07.087Z",
|
342
|
+
# :in_progress_invalidation_batches=>0}
|
343
|
+
#
|
344
|
+
# # Custom Origin
|
345
|
+
#
|
346
|
+
# custom_config = { :comment => "kd: delete me please",
|
347
|
+
# :custom_origin => { :dns_name => "custom_origin.my-site.com",
|
348
|
+
# :http_port => 80,
|
349
|
+
# :https_port => 443,
|
350
|
+
# :origin_protocol_policy => 'match-viewer' },
|
351
|
+
# :enabled => true,
|
352
|
+
# :logging => { :prefix => "kd/log/",
|
353
|
+
# :bucket => "my-bucket.s3.amazonaws.com"}} #=>
|
354
|
+
# { :last_modified_time=>"2010-12-08T14:23:43.522Z",
|
355
|
+
# :status=>"InProgress",
|
356
|
+
# :custom_origin=>
|
357
|
+
# {:http_port=>"80",
|
358
|
+
# :https_port=>"443",
|
359
|
+
# :origin_protocol_policy=>"match-viewer",
|
360
|
+
# :dns_name=>"custom_origin.my-site.com"},
|
361
|
+
# :enabled=>true,
|
362
|
+
# :caller_reference=>"201012081723428499167245",
|
363
|
+
# :in_progress_invalidation_batches=>0,
|
364
|
+
# :e_tag=>"E1ZCJ8N5E52KO6",
|
365
|
+
# :location=>
|
366
|
+
# "https://cloudfront.amazonaws.com/2010-11-01/distribution/EK0AJ4RMNIF2P",
|
367
|
+
# :logging=>{:prefix=>"kd/log/", :bucket=>"my-bucket.s3.amazonaws.com"},
|
368
|
+
# :domain_name=>"do36k7s2wxklg.cloudfront.net",
|
369
|
+
# :comment=>"kd: delete me please",
|
370
|
+
# :aws_id=>"EK0AJ4RMNIF2P"}
|
371
|
+
#
|
372
|
+
def create_distribution(config)
|
325
373
|
config[:caller_reference] ||= generate_call_reference
|
326
374
|
link = generate_request('POST', 'distribution', {}, distribution_config_to_xml(config))
|
327
375
|
merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
|
328
376
|
end
|
377
|
+
alias_method :create_distribution_by_config, :create_distribution
|
329
378
|
|
330
379
|
# Get a distribution's information.
|
331
380
|
# Returns a distribution's information or RightAws::AwsError exception.
|
332
381
|
#
|
333
382
|
# acf.get_distribution('E2REJM3VUN5RSI') #=>
|
334
|
-
# {:
|
335
|
-
# :
|
336
|
-
# :
|
337
|
-
# :
|
338
|
-
# :
|
339
|
-
# :
|
340
|
-
#
|
341
|
-
#
|
342
|
-
#
|
343
|
-
# :
|
383
|
+
# {:last_modified_time=>"2010-05-19T18:54:38.242Z",
|
384
|
+
# :status=>"Deployed",
|
385
|
+
# :domain_name=>"dpzl38cuix402.cloudfront.net",
|
386
|
+
# :caller_reference=>"201005181943052207677116",
|
387
|
+
# :e_tag=>"EJSXFGM5JL8ER",
|
388
|
+
# :s3_origin=>
|
389
|
+
# {:dns_name=>"bucket-for-konstantin-eu.s3.amazonaws.com",
|
390
|
+
# :origin_access_identity=>
|
391
|
+
# "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
|
392
|
+
# :aws_id=>"E5P8HQ3ZAZIXD",
|
393
|
+
# :enabled=>false}
|
344
394
|
#
|
345
395
|
# acf.get_distribution('E2FNSBHNVVF11E') #=>
|
346
396
|
# {:e_tag=>"E1Q2DJEPTQOLJD",
|
@@ -357,9 +407,11 @@ module RightAws
|
|
357
407
|
# {:aws_account_number=>"648772220000"}],
|
358
408
|
# :caller_reference=>"201004171154450740700072",
|
359
409
|
# :domain_name=>"d1f6lpevremt5m.cloudfront.net",
|
360
|
-
# :
|
361
|
-
#
|
362
|
-
#
|
410
|
+
# :s3_origin=>
|
411
|
+
# {:dns_name=>"bucket-for-konstantin-eu.s3.amazonaws.com",
|
412
|
+
# :origin_access_identity=>
|
413
|
+
# "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
|
414
|
+
# :trusted_signers=>["self", "648772220000", "120288270000"]}
|
363
415
|
#
|
364
416
|
def get_distribution(aws_id)
|
365
417
|
link = generate_request('GET', "distribution/#{aws_id}")
|
@@ -370,21 +422,24 @@ module RightAws
|
|
370
422
|
# Returns a distribution's configuration or RightAws::AwsError exception.
|
371
423
|
#
|
372
424
|
# acf.get_distribution_config('E2REJM3VUN5RSI') #=>
|
373
|
-
# {:
|
374
|
-
# :
|
375
|
-
# :
|
376
|
-
#
|
377
|
-
#
|
378
|
-
#
|
425
|
+
# {:caller_reference=>"201005181943052207677116",
|
426
|
+
# :e_tag=>"EJSXFGM5JL8ER",
|
427
|
+
# :s3_origin=>
|
428
|
+
# {:dns_name=>"bucket-for-konstantin-eu.s3.amazonaws.com",
|
429
|
+
# :origin_access_identity=>
|
430
|
+
# "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
|
431
|
+
# :enabled=>false}
|
379
432
|
#
|
380
433
|
# acf.get_distribution_config('E2FNSBHNVVF11E') #=>
|
381
434
|
# {:e_tag=>"E1Q2DJEPTQOLJD",
|
382
435
|
# :logging=>{:prefix=>"xlog/", :bucket=>"my-bucket.s3.amazonaws.com"},
|
383
436
|
# :enabled=>true,
|
384
437
|
# :caller_reference=>"201004171154450740700072",
|
385
|
-
# :origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
|
386
438
|
# :trusted_signers=>["self", "648772220000", "120288270000"],
|
387
|
-
# :
|
439
|
+
# :s3_origin=>
|
440
|
+
# {:dns_name=>"bucket-for-konstantin-eu.s3.amazonaws.com",
|
441
|
+
# :origin_access_identity=>
|
442
|
+
# "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"}}
|
388
443
|
#
|
389
444
|
def get_distribution_config(aws_id)
|
390
445
|
link = generate_request('GET', "distribution/#{aws_id}/config")
|
@@ -392,7 +447,6 @@ module RightAws
|
|
392
447
|
end
|
393
448
|
|
394
449
|
# Set a distribution's configuration
|
395
|
-
# (the :origin and the :caller_reference cannot be changed).
|
396
450
|
# Returns +true+ on success or RightAws::AwsError exception.
|
397
451
|
#
|
398
452
|
# config = acf.get_distribution_config('E2REJM3VUN5RSI') #=>
|
@@ -401,13 +455,13 @@ module RightAws
|
|
401
455
|
# :e_tag => "E39OHHU1ON65SI",
|
402
456
|
# :cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
|
403
457
|
# :comment => "Woo-Hoo!",
|
404
|
-
# :
|
458
|
+
# :s3_origin => { :dns_name => "my-bucket.s3.amazonaws.com"}}
|
405
459
|
#
|
406
460
|
# config[:comment] = 'Olah-lah!'
|
407
461
|
# config[:enabled] = false
|
408
|
-
# config[:origin_access_identity] = "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"
|
462
|
+
# config[:s3_origin][:origin_access_identity] = "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"
|
409
463
|
# # or just
|
410
|
-
# # config[:origin_access_identity] = "E3JPJZ80ZBX24G"
|
464
|
+
# # config[:s3_origin][:origin_access_identity] = "E3JPJZ80ZBX24G"
|
411
465
|
# config[:trusted_signers] = ['self', '648772220000', '120288270000']
|
412
466
|
# config[:logging] = { :bucket => 'my-bucket.s3.amazonaws.com', :prefix => 'xlog/' }
|
413
467
|
#
|
@@ -446,38 +500,48 @@ module RightAws
|
|
446
500
|
%r{^(Streaming)?Distribution$},
|
447
501
|
%r{^(Streaming)?DistributionConfig$}
|
448
502
|
@distribution = { }
|
503
|
+
when %r{/S3Origin$} then @distribution[:s3_origin] = {}
|
504
|
+
when %r{/CustomOrigin$} then @distribution[:custom_origin] = {}
|
449
505
|
end
|
450
506
|
end
|
451
507
|
def tagend(name)
|
452
508
|
case name
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
@
|
509
|
+
when 'Marker' then @result[:marker] = @text
|
510
|
+
when 'NextMarker' then @result[:next_marker] = @text
|
511
|
+
when 'MaxItems' then @result[:max_items] = @text.to_i
|
512
|
+
when 'IsTruncated' then @result[:is_truncated] = (@text == 'true')
|
513
|
+
when 'Id' then @distribution[:aws_id] = @text
|
514
|
+
when 'Status' then @distribution[:status] = @text
|
515
|
+
when 'LastModifiedTime' then @distribution[:last_modified_time] = @text
|
516
|
+
when 'DomainName' then @distribution[:domain_name] = @text
|
517
|
+
when 'Comment' then @distribution[:comment] = AwsUtils::xml_unescape(@text)
|
518
|
+
when 'CallerReference' then @distribution[:caller_reference] = @text
|
519
|
+
when 'CNAME' then (@distribution[:cnames] ||= []) << @text
|
520
|
+
when 'Enabled' then @distribution[:enabled] = (@text == 'true')
|
521
|
+
when 'Bucket' then (@distribution[:logging] ||= {})[:bucket] = @text
|
522
|
+
when 'Prefix' then (@distribution[:logging] ||= {})[:prefix] = @text
|
523
|
+
when 'Protocol' then (@distribution[:required_protocols] ||= {})[:protocol] = @text
|
524
|
+
when 'InProgressInvalidationBatches' then @distribution[:in_progress_invalidation_batches] = @text.to_i
|
525
|
+
when 'DefaultRootObject' then @distribution[:default_root_object] = @text
|
526
|
+
else
|
527
|
+
case full_tag_name
|
528
|
+
when %r{/S3Origin/DNSName$} then @distribution[:s3_origin][:dns_name] = @text
|
529
|
+
when %r{/S3Origin/OriginAccessIdentity$} then @distribution[:s3_origin][:origin_access_identity] = @text
|
530
|
+
when %r{/CustomOrigin/DNSName$} then @distribution[:custom_origin][:dns_name] = @text
|
531
|
+
when %r{/CustomOrigin/HTTPPort} then @distribution[:custom_origin][:http_port] = @text
|
532
|
+
when %r{/CustomOrigin/HTTPSPort$} then @distribution[:custom_origin][:https_port] = @text
|
533
|
+
when %r{/CustomOrigin/OriginProtocolPolicy$} then @distribution[:custom_origin][:origin_protocol_policy] = @text
|
534
|
+
when %r{/TrustedSigners/Self$} then (@distribution[:trusted_signers] ||= []) << 'self'
|
535
|
+
when %r{/TrustedSigners/AwsAccountNumber$} then (@distribution[:trusted_signers] ||= []) << @text
|
536
|
+
when %r{/Signer/Self$} then @active_signer[:aws_account_number] = 'self'
|
537
|
+
when %r{/Signer/AwsAccountNumber$} then @active_signer[:aws_account_number] = @text
|
538
|
+
when %r{/Signer/KeyPairId$} then (@active_signer[:key_pair_ids] ||= []) << @text
|
539
|
+
when %r{/Signer$} then (@distribution[:active_trusted_signers] ||= []) << @active_signer
|
540
|
+
when %r{(Streaming)?DistributionSummary$},
|
541
|
+
%r{^(Streaming)?Distribution$},
|
542
|
+
%r{^(Streaming)?DistributionConfig$}
|
543
|
+
@result[:distributions] << @distribution
|
544
|
+
end
|
481
545
|
end
|
482
546
|
end
|
483
547
|
end
|