aws-sdk 1.5.4 → 1.5.5
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/ca-bundle.crt +54 -444
- data/lib/aws/api_config/EC2-2012-06-01.yml +52 -13
- data/lib/aws/api_config/SimpleEmailService-2010-12-01.yml +53 -0
- data/lib/aws/auto_scaling/request.rb +7 -1
- data/lib/aws/cloud_formation/stack_options.rb +3 -3
- data/lib/aws/core.rb +30 -9
- data/lib/aws/core/client.rb +7 -2
- data/lib/aws/core/configuration.rb +65 -36
- data/lib/aws/core/http/httparty_handler.rb +5 -4
- data/lib/aws/core/http/net_http_handler.rb +30 -14
- data/lib/aws/core/http/request.rb +10 -2
- data/lib/aws/core/inflection.rb +15 -12
- data/lib/aws/core/log_formatter.rb +6 -0
- data/lib/aws/core/resource.rb +7 -3
- data/lib/aws/core/service_interface.rb +3 -3
- data/lib/aws/ec2.rb +7 -0
- data/lib/aws/ec2/client.rb +80 -1
- data/lib/aws/ec2/export_task.rb +120 -0
- data/lib/aws/ec2/export_task_collection.rb +67 -0
- data/lib/aws/ec2/instance.rb +81 -0
- data/lib/aws/ec2/region.rb +1 -0
- data/lib/aws/record/model.rb +1 -1
- data/lib/aws/s3.rb +1 -0
- data/lib/aws/s3/access_control_list.rb +12 -5
- data/lib/aws/s3/acl_options.rb +204 -0
- data/lib/aws/s3/bucket.rb +6 -11
- data/lib/aws/s3/bucket_collection.rb +21 -4
- data/lib/aws/s3/client.rb +280 -96
- data/lib/aws/s3/request.rb +0 -8
- data/lib/aws/s3/s3_object.rb +23 -13
- data/lib/aws/simple_email_service/client.rb +76 -11
- data/lib/aws/simple_email_service/identity.rb +81 -4
- data/lib/net/http/connection_pool.rb +45 -23
- data/lib/net/http/connection_pool/connection.rb +3 -0
- data/lib/net/http/connection_pool/session.rb +2 -2
- metadata +6 -3
@@ -0,0 +1,67 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class EC2
|
16
|
+
|
17
|
+
# = Getting Export Tasks
|
18
|
+
#
|
19
|
+
# Allows you to enumerate export tasks.
|
20
|
+
#
|
21
|
+
# ec2.export_tasks.each do |task|
|
22
|
+
# # yield ExportTask objects
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# You can also get an export task by id
|
26
|
+
#
|
27
|
+
# task = ec2.export_tasks['export-task-id']
|
28
|
+
#
|
29
|
+
# = Creating Export Tasks
|
30
|
+
#
|
31
|
+
# To create an export task you start with the {Instance}:
|
32
|
+
#
|
33
|
+
# task = ec2.instances['i-12345678'].export_to_s3('bucket-name')
|
34
|
+
#
|
35
|
+
# See {Instance#export_to_s3} for more options.
|
36
|
+
#
|
37
|
+
class ExportTaskCollection < Collection
|
38
|
+
|
39
|
+
include Core::Collection::Simple
|
40
|
+
|
41
|
+
# @param [String] export_task_id
|
42
|
+
# @return [ExportTask] Returns reference to the export task with the
|
43
|
+
# given export task id.
|
44
|
+
def [] export_task_id
|
45
|
+
ExportTask.new(export_task_id, :config => config)
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def _each_item options = {}, &block
|
51
|
+
resp = filtered_request(:describe_export_tasks, options, &block)
|
52
|
+
resp.data[:export_task_set].each do |details|
|
53
|
+
|
54
|
+
task = ExportTask.new_from(
|
55
|
+
:describe_export_tasks,
|
56
|
+
details,
|
57
|
+
details[:export_task_id],
|
58
|
+
:config => config)
|
59
|
+
|
60
|
+
yield(task)
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/aws/ec2/instance.rb
CHANGED
@@ -647,6 +647,87 @@ module AWS
|
|
647
647
|
instance_action :stop
|
648
648
|
end
|
649
649
|
|
650
|
+
# This produces an image of an EC2 instance for use in another
|
651
|
+
# virtualization environment and then writes the image to a
|
652
|
+
# S3 bucket.
|
653
|
+
#
|
654
|
+
# == Granting EC2 write access to your bucket
|
655
|
+
#
|
656
|
+
# Before you can export an image to an S3 bucket, you must modify
|
657
|
+
# the bucket ACL. You only need to do this once per bucket.
|
658
|
+
#
|
659
|
+
# s3.buckets['bucket-name'].acl.change do |acl|
|
660
|
+
# acl.grant(:read_acp).to(:amazon_customer_email => 'vm-import-export@amazon.com')
|
661
|
+
# acl.grant(:write).to(:amazon_customer_email => 'vm-import-export@amazon.com')
|
662
|
+
# end
|
663
|
+
#
|
664
|
+
# == Performing the export
|
665
|
+
#
|
666
|
+
# Simply call #export_to_s3 on your instance. Only instances
|
667
|
+
# derived from your own ImportInstance tasks may be exported.
|
668
|
+
#
|
669
|
+
# task = ec2.instances['i-12345678'].export_to_s3('bucket-name')
|
670
|
+
#
|
671
|
+
# == Downloading the results
|
672
|
+
#
|
673
|
+
# Given a completed export task you can download the final image:
|
674
|
+
#
|
675
|
+
# File.open('image.ova', 'w') {|f| f.write(task.s3_object.read) }
|
676
|
+
#
|
677
|
+
# @param [S3::Bucket,String] bucket The destination bucket. May
|
678
|
+
# be the name of the bucket (string) or a {S3::Bucket} object. The
|
679
|
+
# bucket must exist and grant write permissiosn to the AWS account
|
680
|
+
# 'vm-import-export@amazon.com.'.
|
681
|
+
#
|
682
|
+
# @param [Hash] options
|
683
|
+
#
|
684
|
+
# @option options [String] :target_environment ('vmware') The target
|
685
|
+
# virtualization environment. Valid values include: 'vmware', 'citrix'
|
686
|
+
# and 'microsoft'.
|
687
|
+
#
|
688
|
+
# @option options [String] :disk_image_format The format for the exported
|
689
|
+
# image. Defaults to 'vmdk' if +:target_environemnt+ is 'vmware',
|
690
|
+
# otherwise, 'vhd'.
|
691
|
+
#
|
692
|
+
# @option options [String] :container_format The container format used to
|
693
|
+
# combine disk images with metadata (such as OVF). If absent, only
|
694
|
+
# the disk image will be exported. Defaults to 'ova' if
|
695
|
+
# +:target_environment+ is 'vmware', otherwise ommited.
|
696
|
+
#
|
697
|
+
# @option options [String] :description Description of the conversion
|
698
|
+
# task or the resource being exported.
|
699
|
+
#
|
700
|
+
# @option options [String] :prefix (nil) The image is written to a
|
701
|
+
# single object in the bucket at the key:
|
702
|
+
#
|
703
|
+
# "#{prefix}#{export_task_id}.#{disk_image_format}"
|
704
|
+
#
|
705
|
+
# @return [ExportTask]
|
706
|
+
#
|
707
|
+
def export_to_s3 bucket, options = {}
|
708
|
+
|
709
|
+
bucket_name = bucket.is_a?(S3::Bucket) ? bucket.name : bucket.to_s
|
710
|
+
|
711
|
+
opts = {}
|
712
|
+
opts[:instance_id] = instance_id
|
713
|
+
opts[:description] = options[:description] if options[:description]
|
714
|
+
opts[:target_environment] = options[:target_environment] || 'vmware'
|
715
|
+
opts[:export_to_s3] = {}
|
716
|
+
opts[:export_to_s3][:s3_bucket] = bucket_name
|
717
|
+
[:disk_image_format, :container_format, :s3_prefix].each do |opt|
|
718
|
+
opts[:export_to_s3][opt] = options[opt] if options.key?(opt)
|
719
|
+
end
|
720
|
+
|
721
|
+
resp = client.create_instance_export_task(opts)
|
722
|
+
|
723
|
+
ExportTask.new_from(
|
724
|
+
:create_instance_export_task,
|
725
|
+
resp[:export_task],
|
726
|
+
resp[:export_task][:export_task_id],
|
727
|
+
:config => config)
|
728
|
+
|
729
|
+
end
|
730
|
+
|
650
731
|
protected
|
651
732
|
|
652
733
|
def find_in_response resp
|
data/lib/aws/ec2/region.rb
CHANGED
data/lib/aws/record/model.rb
CHANGED
data/lib/aws/s3.rb
CHANGED
@@ -97,6 +97,7 @@ module AWS
|
|
97
97
|
AWS.register_autoloads(self) do
|
98
98
|
autoload :AccessControlList, 'access_control_list'
|
99
99
|
autoload :ACLObject, 'acl_object'
|
100
|
+
autoload :ACLOptions, 'acl_options'
|
100
101
|
autoload :Bucket, 'bucket'
|
101
102
|
autoload :BucketCollection, 'bucket_collection'
|
102
103
|
autoload :BucketLifecycleConfiguration, 'bucket_lifecycle_configuration'
|
@@ -98,13 +98,17 @@ module AWS
|
|
98
98
|
class Grantee
|
99
99
|
include ACLObject
|
100
100
|
|
101
|
-
SIGNAL_ATTRIBUTES = [
|
102
|
-
|
103
|
-
|
101
|
+
SIGNAL_ATTRIBUTES = [
|
102
|
+
:amazon_customer_email,
|
103
|
+
:canonical_user_id,
|
104
|
+
:group_uri,
|
105
|
+
:uri,
|
106
|
+
]
|
104
107
|
|
105
108
|
string_attr "EmailAddress", :method_name => "amazon_customer_email"
|
106
109
|
string_attr "ID", :method_name => "canonical_user_id"
|
107
110
|
string_attr "URI", :method_name => "group_uri"
|
111
|
+
string_attr "URI", :method_name => "uri"
|
108
112
|
string_attr "DisplayName"
|
109
113
|
|
110
114
|
# (see ACLObject#validate!)
|
@@ -133,9 +137,12 @@ module AWS
|
|
133
137
|
|
134
138
|
# @private
|
135
139
|
def type_for_attr(attr)
|
136
|
-
{
|
140
|
+
{
|
141
|
+
:amazon_customer_email => "AmazonCustomerByEmail",
|
137
142
|
:canonical_user_id => "CanonicalUser",
|
138
|
-
:group_uri => "Group"
|
143
|
+
:group_uri => "Group",
|
144
|
+
:uri => "Group",
|
145
|
+
}[attr]
|
139
146
|
end
|
140
147
|
|
141
148
|
end
|
@@ -0,0 +1,204 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'rexml/document'
|
15
|
+
|
16
|
+
module AWS
|
17
|
+
class S3
|
18
|
+
|
19
|
+
# Provides a method to {Bucket} and {S3Object} that parses a wide
|
20
|
+
# range of ACL options.
|
21
|
+
# @private
|
22
|
+
module ACLOptions
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
# @param [Symbol,String,Hash,AccessControlList] acl Accepts an ACL
|
27
|
+
# description in one of the following formats:
|
28
|
+
#
|
29
|
+
# ==== Canned ACL
|
30
|
+
#
|
31
|
+
# S3 supports a number of canned ACLs for buckets and
|
32
|
+
# objects. These include:
|
33
|
+
#
|
34
|
+
# * +:private+
|
35
|
+
# * +:public_read+
|
36
|
+
# * +:public_read_write+
|
37
|
+
# * +:authenticated_read+
|
38
|
+
# * +:bucket_owner_read+ (object-only)
|
39
|
+
# * +:bucket_owner_full_control+ (object-only)
|
40
|
+
# * +:log_delivery_write+ (bucket-only)
|
41
|
+
#
|
42
|
+
# Here is an example of providing a canned ACL to a bucket:
|
43
|
+
#
|
44
|
+
# s3.buckets['bucket-name'].acl = :public_read
|
45
|
+
#
|
46
|
+
# ==== ACL Grant Hash
|
47
|
+
#
|
48
|
+
# You can provide a hash of grants. The hash is composed of grants (keys)
|
49
|
+
# and grantees (values). Accepted grant keys are:
|
50
|
+
#
|
51
|
+
# * +:grant_read+
|
52
|
+
# * +:grant_write+
|
53
|
+
# * +:grant_read_acp+
|
54
|
+
# * +:grant_write_acp+
|
55
|
+
# * +:grant_full_control+
|
56
|
+
#
|
57
|
+
# Grantee strings (values) should be formatted like some of the
|
58
|
+
# following examples:
|
59
|
+
#
|
60
|
+
# id="8a6925ce4adf588a4532142d3f74dd8c71fa124b1ddee97f21c32aa379004fef"
|
61
|
+
# uri="http://acs.amazonaws.com/groups/global/AllUsers"
|
62
|
+
# emailAddress="xyz@amazon.com"
|
63
|
+
#
|
64
|
+
# You can provide a comma delimited list of multiple grantees in a single
|
65
|
+
# string. Please note the use of quotes inside the grantee string.
|
66
|
+
# Here is a simple example:
|
67
|
+
#
|
68
|
+
# {
|
69
|
+
# :grant_full_control => "emailAddress=\"foo@bar.com\", id=\"abc..mno\""
|
70
|
+
# }
|
71
|
+
#
|
72
|
+
# See the S3 API documentation for more information on formatting
|
73
|
+
# grants.
|
74
|
+
#
|
75
|
+
# ==== AcessControlList Object
|
76
|
+
#
|
77
|
+
# You can build an ACL using the {AccessControlList} class and
|
78
|
+
# pass this object.
|
79
|
+
#
|
80
|
+
# acl = AWS::S3::AccessControlList.new
|
81
|
+
# acl.grant(:full_control).to(:canonical_user_id => "8a6...fef")
|
82
|
+
# acl #=> this is acceptible
|
83
|
+
#
|
84
|
+
# ==== ACL XML String
|
85
|
+
#
|
86
|
+
# Lastly you can build your own ACL XML document and pass it as a string.
|
87
|
+
#
|
88
|
+
# <<-XML
|
89
|
+
# <AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
90
|
+
# <Owner>
|
91
|
+
# <ID>8a6...fef</ID>
|
92
|
+
# <DisplayName>owner-display-name</DisplayName>
|
93
|
+
# </Owner>
|
94
|
+
# <AccessControlList>
|
95
|
+
# <Grant>
|
96
|
+
# <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Canonical User">
|
97
|
+
# <ID>8a6...fef</ID>
|
98
|
+
# <DisplayName>owner-display-name</DisplayName>
|
99
|
+
# </Grantee>
|
100
|
+
# <Permission>FULL_CONTROL</Permission>
|
101
|
+
# </Grant>
|
102
|
+
# </AccessControlList>
|
103
|
+
# </AccessControlPolicy>
|
104
|
+
# XML
|
105
|
+
#
|
106
|
+
# @return [Hash] Returns a hash of options suitable for
|
107
|
+
# passing to {Client#put_bucket_acl} and {Client#put_object_acl}
|
108
|
+
# with a mixture of ACL options.
|
109
|
+
#
|
110
|
+
def acl_options acl
|
111
|
+
case acl
|
112
|
+
when Symbol
|
113
|
+
{ :acl => acl.to_s.tr('_', '-') }
|
114
|
+
when String
|
115
|
+
# Strings are either access control policies (xml strings)
|
116
|
+
# or they are canned acls
|
117
|
+
xml?(acl) ?
|
118
|
+
{ :access_control_policy => acl } :
|
119
|
+
{ :acl => acl }
|
120
|
+
when AccessControlList
|
121
|
+
{ :access_control_policy => acl.to_xml }
|
122
|
+
when Hash
|
123
|
+
# Hashes are either grant hashes or constructor args for an
|
124
|
+
# access control list (deprecated)
|
125
|
+
grant_hash?(acl) ?
|
126
|
+
format_grants(acl) :
|
127
|
+
{ :access_control_policy => AccessControlList.new(acl).to_xml }
|
128
|
+
else
|
129
|
+
# failed to parse the acl option
|
130
|
+
msg = "expected a canned ACL, AccessControlList object, ACL "
|
131
|
+
"XML string or a grants hash"
|
132
|
+
raise ArgumentError, msg
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# @param [Hash] acl_hash
|
137
|
+
# @return [Boolean] Retursn +true+ if this hash is a hash of grants.
|
138
|
+
def grant_hash? acl_hash
|
139
|
+
grant_keys = [
|
140
|
+
:grant_read,
|
141
|
+
:grant_write,
|
142
|
+
:grant_read_acp,
|
143
|
+
:grant_write_acp,
|
144
|
+
:grant_full_control,
|
145
|
+
]
|
146
|
+
acl_hash.keys.all?{|key| grant_keys.include?(key) }
|
147
|
+
end
|
148
|
+
|
149
|
+
# @param [String] acl_string
|
150
|
+
# @return [Boolean] Returns +true+ if this string is an xml document.
|
151
|
+
def xml? acl_string
|
152
|
+
begin
|
153
|
+
REXML::Document.new(acl_string).has_elements?
|
154
|
+
rescue
|
155
|
+
false
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# @param [Hash] acl_hash
|
160
|
+
# @return [Hash] Returns a hash of grant options suitable for
|
161
|
+
# passing to the various S3 client methods that accept ACL grants.
|
162
|
+
def format_grants acl_hash
|
163
|
+
grants = {}
|
164
|
+
acl_hash.each_pair do |grant,grantees|
|
165
|
+
grantees = [grantees] unless grantees.is_a?(Array)
|
166
|
+
grants[grant] = grantees.map{|g| format_grantee(g) }.join(', ')
|
167
|
+
end
|
168
|
+
grants
|
169
|
+
end
|
170
|
+
|
171
|
+
def format_grantee grantee
|
172
|
+
case grantee
|
173
|
+
when String then grantee
|
174
|
+
when Hash
|
175
|
+
|
176
|
+
if grantee.keys.count != 1
|
177
|
+
msg = "grantee hashes must have exactly 1 key"
|
178
|
+
raise ArgumentError, msg
|
179
|
+
end
|
180
|
+
|
181
|
+
# A granee hash looks like:
|
182
|
+
# { :id => 'abc...fec' }
|
183
|
+
# { :uri => 'http://abc.com/foo' }
|
184
|
+
# { :email_address => 'xyz@amazon.com }
|
185
|
+
#
|
186
|
+
# It needs to look like
|
187
|
+
# 'id="abc...fec"'
|
188
|
+
# 'uri="http://abc.com/foo"'
|
189
|
+
# 'emailAddress="xyz@amazon.com"'
|
190
|
+
type, token = grantee.to_a.flatten
|
191
|
+
type = type.to_s.split('_').map{|part| ucfirst(part) }.join
|
192
|
+
"#{type[0,1].downcase}#{type[1..-1]}=\"#{token}\""
|
193
|
+
else
|
194
|
+
raise ArgumentError, "grantees must be a string or a hash"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def ucfirst str
|
199
|
+
str[0,1].upcase + str[1..-1]
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
data/lib/aws/s3/bucket.rb
CHANGED
@@ -27,6 +27,7 @@ module AWS
|
|
27
27
|
class Bucket
|
28
28
|
|
29
29
|
include Core::Model
|
30
|
+
include ACLOptions
|
30
31
|
|
31
32
|
# @param [String] name
|
32
33
|
# @param [Hash] options
|
@@ -212,18 +213,12 @@ module AWS
|
|
212
213
|
|
213
214
|
end
|
214
215
|
|
215
|
-
# Sets the bucket's access control list.
|
216
|
-
#
|
217
|
-
#
|
218
|
-
# * An AccessControlList object
|
219
|
-
# * Any object that responds to +to_xml+
|
220
|
-
# * Any Hash that is acceptable as an argument to
|
221
|
-
# AccessControlList#initialize.
|
222
|
-
#
|
223
|
-
# @param [AccessControlList] acl
|
216
|
+
# Sets the bucket's ACL (access control list). You can provide an ACL
|
217
|
+
# in a number of different formats.
|
218
|
+
# @param (see ACLOptions#acl_options)
|
224
219
|
# @return [nil]
|
225
|
-
def acl=
|
226
|
-
client.set_bucket_acl(:bucket_name => name
|
220
|
+
def acl= acl
|
221
|
+
client.set_bucket_acl(acl_options(acl).merge(:bucket_name => name))
|
227
222
|
nil
|
228
223
|
end
|
229
224
|
|