aws-sdk 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ca-bundle.crt +2 -348
- data/lib/aws.rb +24 -49
- data/lib/aws/{common.rb → core.rb} +120 -9
- data/lib/aws/{api_config.rb → core/api_config.rb} +19 -20
- data/lib/aws/core/api_config_transform.rb +36 -0
- data/lib/aws/core/async_handle.rb +91 -0
- data/lib/aws/core/authorize_v2.rb +39 -0
- data/lib/aws/{authorize_v3.rb → core/authorize_v3.rb} +16 -15
- data/lib/aws/{api_config_transform.rb → core/authorize_with_session_token.rb} +9 -12
- data/lib/aws/core/autoloader.rb +64 -0
- data/lib/aws/core/cacheable.rb +78 -0
- data/lib/aws/core/client.rb +471 -0
- data/lib/aws/core/client_logging.rb +125 -0
- data/lib/aws/core/collections.rb +229 -0
- data/lib/aws/core/configuration.rb +358 -0
- data/lib/aws/core/configured_client_methods.rb +76 -0
- data/lib/aws/core/configured_grammars.rb +63 -0
- data/lib/aws/{configured_option_grammars.rb → core/configured_option_grammars.rb} +18 -20
- data/lib/aws/{configured_xml_grammars.rb → core/configured_xml_grammars.rb} +19 -21
- data/lib/aws/core/default_signer.rb +67 -0
- data/lib/aws/core/http/curb_handler.rb +129 -0
- data/lib/aws/core/http/handler.rb +77 -0
- data/lib/aws/core/http/httparty_handler.rb +113 -0
- data/lib/aws/core/http/net_http_handler.rb +124 -0
- data/lib/aws/core/http/request.rb +207 -0
- data/lib/aws/core/http/response.rb +73 -0
- data/lib/aws/{ignore_result_element.rb → core/ignore_result_element.rb} +14 -18
- data/lib/aws/core/indifferent_hash.rb +88 -0
- data/lib/aws/core/inflection.rb +47 -0
- data/lib/aws/core/lazy_error_classes.rb +62 -0
- data/lib/aws/{uri_escape.rb → core/meta_utils.rb} +24 -23
- data/lib/aws/core/model.rb +57 -0
- data/lib/aws/{authorize_with_session_token.rb → core/naming.rb} +9 -8
- data/lib/aws/core/option_grammar.rb +562 -0
- data/lib/aws/core/policy.rb +914 -0
- data/lib/aws/core/resource.rb +380 -0
- data/lib/aws/core/resource_cache.rb +40 -0
- data/lib/aws/core/response.rb +125 -0
- data/lib/aws/core/response_cache.rb +50 -0
- data/lib/aws/core/service_interface.rb +60 -0
- data/lib/aws/core/uri_escape.rb +46 -0
- data/lib/aws/core/xml_grammar.rb +926 -0
- data/lib/aws/ec2.rb +47 -16
- data/lib/aws/ec2/attachment.rb +0 -2
- data/lib/aws/ec2/attachment_collection.rb +1 -6
- data/lib/aws/ec2/availability_zone.rb +0 -2
- data/lib/aws/ec2/availability_zone_collection.rb +0 -3
- data/lib/aws/ec2/client.rb +6 -9
- data/lib/aws/ec2/client/xml.rb +3 -6
- data/lib/aws/ec2/collection.rb +1 -4
- data/lib/aws/ec2/config.rb +18 -0
- data/lib/aws/ec2/elastic_ip.rb +0 -2
- data/lib/aws/ec2/elastic_ip_collection.rb +0 -4
- data/lib/aws/ec2/errors.rb +1 -4
- data/lib/aws/ec2/has_permissions.rb +0 -2
- data/lib/aws/ec2/image.rb +0 -5
- data/lib/aws/ec2/image_collection.rb +0 -6
- data/lib/aws/ec2/instance.rb +23 -9
- data/lib/aws/ec2/instance_collection.rb +85 -22
- data/lib/aws/ec2/key_pair.rb +0 -2
- data/lib/aws/ec2/key_pair_collection.rb +1 -4
- data/lib/aws/ec2/permission_collection.rb +2 -5
- data/lib/aws/ec2/region.rb +0 -2
- data/lib/aws/ec2/region_collection.rb +0 -4
- data/lib/aws/ec2/request.rb +4 -9
- data/lib/aws/ec2/reserved_instances.rb +0 -3
- data/lib/aws/ec2/reserved_instances_collection.rb +0 -4
- data/lib/aws/ec2/reserved_instances_offering.rb +0 -3
- data/lib/aws/ec2/reserved_instances_offering_collection.rb +0 -4
- data/lib/aws/ec2/resource.rb +3 -5
- data/lib/aws/ec2/resource_tag_collection.rb +1 -6
- data/lib/aws/ec2/security_group.rb +204 -72
- data/lib/aws/ec2/security_group/egress_ip_permission_collection.rb +53 -0
- data/lib/aws/ec2/security_group/ip_permission.rb +92 -10
- data/lib/aws/ec2/security_group/ip_permission_collection.rb +14 -15
- data/lib/aws/ec2/security_group_collection.rb +11 -8
- data/lib/aws/ec2/snapshot.rb +0 -4
- data/lib/aws/ec2/snapshot_collection.rb +0 -4
- data/lib/aws/ec2/tag.rb +0 -3
- data/lib/aws/ec2/tag_collection.rb +1 -8
- data/lib/aws/ec2/tagged_item.rb +1 -3
- data/lib/aws/ec2/volume.rb +0 -6
- data/lib/aws/ec2/volume_collection.rb +0 -4
- data/lib/aws/errors.rb +0 -3
- data/lib/aws/iam.rb +33 -12
- data/lib/aws/iam/access_key.rb +0 -3
- data/lib/aws/iam/access_key_collection.rb +0 -3
- data/lib/aws/iam/account_alias_collection.rb +0 -2
- data/lib/aws/iam/client.rb +6 -8
- data/lib/aws/iam/client/xml.rb +4 -8
- data/lib/aws/iam/collection.rb +2 -5
- data/lib/aws/iam/config.rb +18 -0
- data/lib/aws/iam/errors.rb +2 -4
- data/lib/aws/iam/group.rb +0 -5
- data/lib/aws/iam/group_collection.rb +0 -3
- data/lib/aws/iam/group_policy_collection.rb +0 -2
- data/lib/aws/iam/group_user_collection.rb +1 -4
- data/lib/aws/iam/login_profile.rb +0 -2
- data/lib/aws/iam/mfa_device.rb +1 -3
- data/lib/aws/iam/mfa_device_collection.rb +0 -3
- data/lib/aws/iam/policy.rb +2 -4
- data/lib/aws/iam/policy_collection.rb +0 -3
- data/lib/aws/iam/request.rb +3 -7
- data/lib/aws/iam/resource.rb +1 -4
- data/lib/aws/iam/server_certificate.rb +0 -2
- data/lib/aws/iam/server_certificate_collection.rb +0 -3
- data/lib/aws/iam/signing_certificate.rb +0 -2
- data/lib/aws/iam/signing_certificate_collection.rb +0 -3
- data/lib/aws/iam/user.rb +0 -7
- data/lib/aws/iam/user_collection.rb +0 -3
- data/lib/aws/iam/user_group_collection.rb +0 -3
- data/lib/aws/iam/user_policy.rb +0 -2
- data/lib/aws/iam/user_policy_collection.rb +0 -3
- data/lib/aws/rails.rb +5 -4
- data/lib/aws/record.rb +4 -1
- data/lib/aws/record/base.rb +3 -2
- data/lib/aws/record/errors.rb +1 -3
- data/lib/aws/s3.rb +31 -6
- data/lib/aws/s3/access_control_list.rb +0 -2
- data/lib/aws/s3/acl_object.rb +10 -12
- data/lib/aws/s3/bucket.rb +1 -9
- data/lib/aws/s3/bucket_collection.rb +2 -5
- data/lib/aws/s3/bucket_version_collection.rb +1 -5
- data/lib/aws/s3/client.rb +34 -37
- data/lib/aws/s3/client/xml.rb +11 -14
- data/lib/aws/{resource_cache.rb → s3/config.rb} +6 -20
- data/lib/aws/s3/errors.rb +6 -7
- data/lib/aws/s3/multipart_upload.rb +1 -4
- data/lib/aws/s3/multipart_upload_collection.rb +1 -6
- data/lib/aws/s3/object_collection.rb +1 -5
- data/lib/aws/s3/object_metadata.rb +1 -3
- data/lib/aws/s3/object_upload_collection.rb +1 -7
- data/lib/aws/s3/object_version.rb +1 -4
- data/lib/aws/s3/object_version_collection.rb +1 -4
- data/lib/aws/s3/policy.rb +3 -5
- data/lib/aws/s3/prefix_and_delimiter_collection.rb +0 -2
- data/lib/aws/s3/prefixed_collection.rb +0 -2
- data/lib/aws/s3/presigned_post.rb +1 -3
- data/lib/aws/s3/request.rb +2 -5
- data/lib/aws/s3/s3_object.rb +1 -8
- data/lib/aws/s3/tree.rb +8 -6
- data/lib/aws/s3/tree/branch_node.rb +0 -3
- data/lib/aws/s3/tree/child_collection.rb +1 -5
- data/lib/aws/s3/tree/leaf_node.rb +0 -5
- data/lib/aws/s3/tree/parent.rb +1 -4
- data/lib/aws/s3/uploaded_part.rb +1 -3
- data/lib/aws/s3/uploaded_part_collection.rb +1 -5
- data/lib/aws/simple_db.rb +21 -6
- data/lib/aws/simple_db/attribute.rb +1 -6
- data/lib/aws/simple_db/attribute_collection.rb +1 -7
- data/lib/aws/simple_db/client.rb +7 -9
- data/lib/aws/simple_db/client/options.rb +2 -4
- data/lib/aws/simple_db/client/xml.rb +5 -10
- data/lib/aws/{naming.rb → simple_db/config.rb} +3 -14
- data/lib/aws/simple_db/delete_attributes.rb +0 -2
- data/lib/aws/simple_db/domain.rb +1 -6
- data/lib/aws/simple_db/domain_collection.rb +1 -4
- data/lib/aws/simple_db/domain_metadata.rb +1 -3
- data/lib/aws/simple_db/errors.rb +1 -4
- data/lib/aws/simple_db/item.rb +1 -7
- data/lib/aws/simple_db/item_collection.rb +22 -23
- data/lib/aws/simple_db/put_attributes.rb +0 -2
- data/lib/aws/simple_db/request.rb +3 -7
- data/lib/aws/simple_email_service.rb +11 -6
- data/lib/aws/simple_email_service/client.rb +7 -9
- data/lib/aws/simple_email_service/client/options.rb +3 -6
- data/lib/aws/simple_email_service/client/xml.rb +4 -8
- data/lib/aws/simple_email_service/config.rb +19 -0
- data/lib/aws/simple_email_service/email_address_collection.rb +1 -3
- data/lib/aws/simple_email_service/errors.rb +1 -4
- data/lib/aws/simple_email_service/quotas.rb +1 -3
- data/lib/aws/simple_email_service/request.rb +3 -7
- data/lib/aws/sns.rb +15 -8
- data/lib/aws/sns/client.rb +7 -8
- data/lib/aws/sns/client/options.rb +3 -6
- data/lib/aws/sns/client/xml.rb +4 -8
- data/lib/aws/sns/config.rb +18 -0
- data/lib/aws/sns/errors.rb +1 -4
- data/lib/aws/sns/policy.rb +3 -5
- data/lib/aws/sns/request.rb +4 -9
- data/lib/aws/sns/subscription.rb +1 -5
- data/lib/aws/sns/subscription_collection.rb +1 -5
- data/lib/aws/sns/topic.rb +1 -6
- data/lib/aws/sns/topic_collection.rb +1 -4
- data/lib/aws/sns/topic_subscription_collection.rb +1 -4
- data/lib/aws/sqs.rb +14 -5
- data/lib/aws/sqs/client.rb +6 -9
- data/lib/aws/sqs/client/xml.rb +4 -7
- data/lib/aws/sqs/config.rb +18 -0
- data/lib/aws/sqs/errors.rb +1 -4
- data/lib/aws/sqs/policy.rb +3 -5
- data/lib/aws/sqs/queue.rb +2 -7
- data/lib/aws/sqs/queue_collection.rb +4 -5
- data/lib/aws/sqs/received_message.rb +1 -3
- data/lib/aws/sqs/received_sns_message.rb +2 -2
- data/lib/aws/sqs/request.rb +4 -7
- data/lib/aws/sts.rb +12 -6
- data/lib/aws/sts/client.rb +6 -8
- data/lib/aws/sts/client/xml.rb +4 -8
- data/lib/aws/sts/config.rb +18 -0
- data/lib/aws/sts/errors.rb +1 -4
- data/lib/aws/sts/federated_session.rb +0 -2
- data/lib/aws/sts/policy.rb +3 -5
- data/lib/aws/sts/request.rb +3 -7
- metadata +60 -50
- data/lib/aws/async_handle.rb +0 -90
- data/lib/aws/authorize_v2.rb +0 -37
- data/lib/aws/base_client.rb +0 -488
- data/lib/aws/cacheable.rb +0 -79
- data/lib/aws/client_logging.rb +0 -122
- data/lib/aws/collections.rb +0 -230
- data/lib/aws/configuration.rb +0 -357
- data/lib/aws/configured_client_methods.rb +0 -81
- data/lib/aws/configured_grammars.rb +0 -65
- data/lib/aws/default_signer.rb +0 -65
- data/lib/aws/http/curb_handler.rb +0 -127
- data/lib/aws/http/handler.rb +0 -77
- data/lib/aws/http/httparty_handler.rb +0 -103
- data/lib/aws/http/request.rb +0 -165
- data/lib/aws/http/request_param.rb +0 -64
- data/lib/aws/http/response.rb +0 -72
- data/lib/aws/indifferent_hash.rb +0 -86
- data/lib/aws/inflection.rb +0 -46
- data/lib/aws/lazy_error_classes.rb +0 -64
- data/lib/aws/meta_utils.rb +0 -43
- data/lib/aws/model.rb +0 -57
- data/lib/aws/option_grammar.rb +0 -565
- data/lib/aws/policy.rb +0 -914
- data/lib/aws/resource.rb +0 -381
- data/lib/aws/response.rb +0 -125
- data/lib/aws/response_cache.rb +0 -50
- data/lib/aws/service_interface.rb +0 -60
- data/lib/aws/xml_grammar.rb +0 -925
data/lib/aws/ec2/key_pair.rb
CHANGED
@@ -11,11 +11,8 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/model'
|
15
|
-
require 'aws/ec2/collection'
|
16
|
-
require 'aws/ec2/key_pair'
|
17
|
-
require 'digest/md5'
|
18
14
|
require 'base64'
|
15
|
+
require 'digest/md5'
|
19
16
|
|
20
17
|
module AWS
|
21
18
|
class EC2
|
@@ -11,9 +11,6 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/model'
|
15
|
-
require 'aws/inflection'
|
16
|
-
|
17
14
|
module AWS
|
18
15
|
class EC2
|
19
16
|
|
@@ -24,7 +21,7 @@ module AWS
|
|
24
21
|
# that use this interface.
|
25
22
|
class PermissionCollection
|
26
23
|
|
27
|
-
include Model
|
24
|
+
include Core::Model
|
28
25
|
include Enumerable
|
29
26
|
|
30
27
|
# @private
|
@@ -137,7 +134,7 @@ module AWS
|
|
137
134
|
# @private
|
138
135
|
private
|
139
136
|
def inflected_permissions_attribute
|
140
|
-
Inflection.ruby_name(permissions_attribute).to_sym
|
137
|
+
Core::Inflection.ruby_name(permissions_attribute).to_sym
|
141
138
|
end
|
142
139
|
|
143
140
|
# @private
|
data/lib/aws/ec2/region.rb
CHANGED
@@ -11,10 +11,6 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/model'
|
15
|
-
require 'aws/ec2/collection'
|
16
|
-
require 'aws/ec2/region'
|
17
|
-
|
18
14
|
module AWS
|
19
15
|
class EC2
|
20
16
|
|
data/lib/aws/ec2/request.rb
CHANGED
@@ -11,19 +11,14 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/http/request'
|
15
|
-
require 'aws/authorize_v2'
|
16
|
-
require 'aws/authorize_with_session_token'
|
17
|
-
|
18
14
|
module AWS
|
19
15
|
class EC2
|
20
16
|
|
21
17
|
# @private
|
22
|
-
class Request <
|
23
|
-
|
24
|
-
include
|
25
|
-
include AuthorizeWithSessionToken
|
26
|
-
|
18
|
+
class Request < Core::Http::Request
|
19
|
+
include Core::AuthorizeV2
|
20
|
+
include Core::AuthorizeWithSessionToken
|
27
21
|
end
|
22
|
+
|
28
23
|
end
|
29
24
|
end
|
@@ -11,9 +11,6 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/ec2/resource'
|
15
|
-
require 'aws/ec2/tagged_item'
|
16
|
-
|
17
14
|
module AWS
|
18
15
|
class EC2
|
19
16
|
class ReservedInstances < Resource
|
@@ -11,10 +11,6 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/ec2/collection'
|
15
|
-
require 'aws/ec2/reserved_instances'
|
16
|
-
require 'aws/ec2/tagged_collection'
|
17
|
-
|
18
14
|
module AWS
|
19
15
|
class EC2
|
20
16
|
class ReservedInstancesCollection < Collection
|
@@ -11,9 +11,6 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/ec2/resource'
|
15
|
-
require 'aws/ec2/tagged_item'
|
16
|
-
|
17
14
|
module AWS
|
18
15
|
class EC2
|
19
16
|
class ReservedInstancesOffering < Resource
|
@@ -11,10 +11,6 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/ec2/collection'
|
15
|
-
require 'aws/ec2/tagged_collection'
|
16
|
-
require 'aws/ec2/reserved_instances_offering'
|
17
|
-
|
18
14
|
module AWS
|
19
15
|
class EC2
|
20
16
|
class ReservedInstancesOfferingCollection < Collection
|
data/lib/aws/ec2/resource.rb
CHANGED
@@ -11,13 +11,11 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/resource'
|
15
|
-
|
16
14
|
module AWS
|
17
15
|
class EC2
|
18
16
|
|
19
17
|
# @private
|
20
|
-
class Resource <
|
18
|
+
class Resource < Core::Resource
|
21
19
|
|
22
20
|
# @private
|
23
21
|
protected
|
@@ -78,7 +76,7 @@ module AWS
|
|
78
76
|
def describe_attribute_call(attribute)
|
79
77
|
name = describe_attribute_call_name
|
80
78
|
|
81
|
-
attr_opt_name = Inflection.class_name(attribute.get_as.to_s)
|
79
|
+
attr_opt_name = Core::Inflection.class_name(attribute.get_as.to_s)
|
82
80
|
attr_opt_name = attr_opt_name[0,1].downcase + attr_opt_name[1..-1]
|
83
81
|
|
84
82
|
client.send(name, Hash[[[response_id_method.to_sym,
|
@@ -119,7 +117,7 @@ module AWS
|
|
119
117
|
|
120
118
|
protected
|
121
119
|
def inflected_name
|
122
|
-
Inflection.ruby_name(class_name)
|
120
|
+
Core::Inflection.ruby_name(class_name)
|
123
121
|
end
|
124
122
|
|
125
123
|
protected
|
@@ -11,11 +11,6 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/model'
|
15
|
-
require 'aws/inflection'
|
16
|
-
require 'aws/ec2/resource'
|
17
|
-
require 'aws/ec2/tag'
|
18
|
-
|
19
14
|
module AWS
|
20
15
|
class EC2
|
21
16
|
|
@@ -29,7 +24,7 @@ module AWS
|
|
29
24
|
# i.tags.stage # => "production"
|
30
25
|
class ResourceTagCollection
|
31
26
|
|
32
|
-
include Model
|
27
|
+
include Core::Model
|
33
28
|
include Enumerable
|
34
29
|
|
35
30
|
# @private
|
@@ -11,11 +11,6 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'aws/ec2/resource'
|
15
|
-
require 'aws/ec2/tagged_item'
|
16
|
-
require 'aws/ec2/security_group/ip_permission'
|
17
|
-
require 'aws/ec2/security_group/ip_permission_collection'
|
18
|
-
|
19
14
|
module AWS
|
20
15
|
class EC2
|
21
16
|
|
@@ -28,19 +23,26 @@ module AWS
|
|
28
23
|
#
|
29
24
|
# @attr_reader [String] owner_id The security group owner's id.
|
30
25
|
#
|
26
|
+
# @attr_reader [String,nil] vpc_id If this is a VPC security group,
|
27
|
+
# vpc_id is the ID of the VPC this group was created in.
|
28
|
+
# Returns false otherwise.
|
29
|
+
#
|
31
30
|
class SecurityGroup < Resource
|
32
31
|
|
32
|
+
AWS.register_autoloads(self, 'aws/ec2/security_group') do
|
33
|
+
autoload :IpPermission, 'ip_permission'
|
34
|
+
autoload :IpPermissionCollection, 'ip_permission_collection'
|
35
|
+
autoload :EgressIpPermissionCollection, 'egress_ip_permission_collection'
|
36
|
+
end
|
37
|
+
|
33
38
|
include TaggedItem
|
34
39
|
|
35
40
|
def initialize id, options = {}
|
36
41
|
@id = id
|
37
|
-
@name = options[:name]
|
38
|
-
@description = options[:description]
|
39
|
-
@owner_id = options[:owner_id]
|
40
42
|
super
|
41
43
|
end
|
42
44
|
|
43
|
-
# @return [String] The
|
45
|
+
# @return [String] The ID of the security group.
|
44
46
|
attr_reader :id
|
45
47
|
|
46
48
|
alias_method :group_id, :id
|
@@ -49,10 +51,14 @@ module AWS
|
|
49
51
|
|
50
52
|
attribute :owner_id, :static => true
|
51
53
|
|
54
|
+
attribute :vpc_id, :static => true
|
55
|
+
|
52
56
|
attribute :description, :as => :group_description, :static => true
|
53
57
|
|
54
58
|
attribute :ip_permissions_list, :as => :ip_permissions
|
55
59
|
|
60
|
+
attribute :ip_permissions_list_egress, :as => :ip_permissions_egress
|
61
|
+
|
56
62
|
populates_from(:describe_security_groups) do |resp|
|
57
63
|
resp.security_group_index[id]
|
58
64
|
end
|
@@ -64,12 +70,30 @@ module AWS
|
|
64
70
|
]).security_group_index.key?(id)
|
65
71
|
end
|
66
72
|
|
73
|
+
# Returns true if this security group is a VPC security group and
|
74
|
+
# not an EC2 security group. VPC security groups belong to a VPC
|
75
|
+
# subnet and can have egress rules.
|
76
|
+
# @return [Boolean] Returns true if this is a VPC security group and
|
77
|
+
# false if this is an EC2 security group.
|
78
|
+
def vpc?
|
79
|
+
vpc_id ? true : false
|
80
|
+
end
|
81
|
+
|
67
82
|
# @return [SecurityGroup::IpPermissionCollection] Returns a
|
68
83
|
# collection of {IpPermission} objects that represents all of
|
69
|
-
# the permissions this security group has
|
70
|
-
|
84
|
+
# the (ingress) permissions this security group has
|
85
|
+
# authorizations for.
|
86
|
+
def ingress_ip_permissions
|
71
87
|
IpPermissionCollection.new(self, :config => config)
|
72
88
|
end
|
89
|
+
alias_method :ip_permissions, :ingress_ip_permissions
|
90
|
+
|
91
|
+
# @return [SecurityGroup::EgressIpPermissionCollection] Returns a
|
92
|
+
# collection of {IpPermission} objects that represents all of
|
93
|
+
# the egress permissions this security group has authorizations for.
|
94
|
+
def egress_ip_permissions
|
95
|
+
EgressIpPermissionCollection.new(self, :config => config)
|
96
|
+
end
|
73
97
|
|
74
98
|
# Adds ingress rules for ICMP pings. Defaults to 0.0.0.0/0 for
|
75
99
|
# the list of allowed IP ranges the ping can come from.
|
@@ -81,6 +105,8 @@ module AWS
|
|
81
105
|
#
|
82
106
|
# @param [String] ip_ranges One or more IP ranges to allow ping from.
|
83
107
|
# Defaults to 0.0.0.0/0
|
108
|
+
# @return [IpPermission] Returns an IpPermission object that was added
|
109
|
+
# to this security group.
|
84
110
|
def allow_ping *sources
|
85
111
|
sources << '0.0.0.0/0' if sources.empty?
|
86
112
|
authorize_ingress('icmp', -1, *sources)
|
@@ -91,48 +117,52 @@ module AWS
|
|
91
117
|
#
|
92
118
|
# @param [String] ip_ranges One or more IP ranges to allow ping from.
|
93
119
|
# Defaults to 0.0.0.0/0
|
120
|
+
# @return [IpPermission] Returns an IpPermission object that was added
|
121
|
+
# to this security group.
|
94
122
|
def disallow_ping *sources
|
95
123
|
sources << '0.0.0.0/0' if sources.empty?
|
96
124
|
revoke_ingress('icmp', -1, *sources)
|
97
125
|
end
|
98
126
|
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
# and a list of sources.
|
103
|
-
#
|
127
|
+
# Add an ingress rules to this security group.
|
128
|
+
# Ingress rules permit inbound traffic over a given protocol for
|
129
|
+
# a given port range from one or more souce ip addresses.
|
104
130
|
#
|
105
131
|
# This example grants the whole internet (0.0.0.0/0) access to port 80
|
106
132
|
# over TCP (HTTP web traffic).
|
107
133
|
#
|
108
|
-
#
|
134
|
+
# security_group.authorize_ingress(:tcp, 80)
|
109
135
|
#
|
110
|
-
#
|
136
|
+
# You can specify port ranges as well:
|
137
|
+
#
|
138
|
+
# # ftp
|
139
|
+
# security_group.authorize_ingress(:tcp, 20..21)
|
140
|
+
#
|
141
|
+
# In the following example allow incoming SSH from a list of
|
111
142
|
# IP address.
|
112
143
|
#
|
113
|
-
#
|
144
|
+
# security_group.authorize_ingress(:tcp, 22,
|
114
145
|
# '111.111.111.111/0', '222.222.222.222/0')
|
115
146
|
#
|
116
|
-
# You can also
|
117
|
-
#
|
118
|
-
#
|
147
|
+
# You can also pass another security group as an ingress source.
|
148
|
+
# Allows traffic through that originates from EC2 instances inside
|
149
|
+
# the given security group.
|
119
150
|
#
|
120
|
-
# web = security_groups
|
121
|
-
# db = security_groups
|
151
|
+
# web = security_groups.create('webservers')
|
152
|
+
# db = security_groups.create('database')
|
122
153
|
#
|
154
|
+
# # allows ec2 instances in the webservers security group to make
|
155
|
+
# # tcp requests via port 3306 to instances in the database
|
156
|
+
# # security group
|
123
157
|
# db.authorize_ingress(:tcp, 3306, web)
|
124
158
|
#
|
125
|
-
# You can
|
126
|
-
#
|
127
|
-
# security_groups['ftpsvr'].authorize_ingress(:tcp, 20..21)
|
128
|
-
#
|
129
|
-
# You can even mix and match IP address and security groups.
|
159
|
+
# You can even mix and match IP address and security group sources.
|
130
160
|
#
|
131
161
|
# @param [String, Symbol] protocol Should be :tcp, :udp or :icmp
|
132
162
|
# or the string equivalent.
|
133
163
|
#
|
134
164
|
# @param [Integer, Range] ports The port (or port range) to allow
|
135
|
-
#
|
165
|
+
# traffic through. You can pass a single integer (like 80)
|
136
166
|
# or a range (like 20..21).
|
137
167
|
#
|
138
168
|
# @param [Mixed] sources One or more CIDR IP addresses,
|
@@ -142,23 +172,81 @@ module AWS
|
|
142
172
|
# user id should be the owner_id (account id) of the security
|
143
173
|
# group.
|
144
174
|
#
|
145
|
-
# @return [
|
175
|
+
# @return [IpPermission] Returns an IpPermission object that was added
|
176
|
+
# to this security group.
|
177
|
+
#
|
146
178
|
def authorize_ingress protocol, ports, *sources
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
179
|
+
parse_ingress_sources(sources) do |options|
|
180
|
+
permission = IpPermission.new(self, protocol, ports, options)
|
181
|
+
permission.authorize
|
182
|
+
permission
|
183
|
+
end
|
152
184
|
end
|
153
185
|
|
154
|
-
#
|
155
|
-
#
|
186
|
+
# Revokes an ingress (inbound) ip permission. This is the inverse
|
187
|
+
# operation to {#authorize_ingress}. See {#authorize_ingress}
|
188
|
+
# for param and option documentation.
|
189
|
+
# @see #authorize_ingress
|
190
|
+
# @return [IpPermission] Returns an IpPermission object that was added
|
191
|
+
# to this security group.
|
156
192
|
def revoke_ingress protocol, ports, *sources
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
193
|
+
parse_ingress_sources(sources) do |options|
|
194
|
+
permission = IpPermission.new(self, protocol, ports, options)
|
195
|
+
permission.revoke
|
196
|
+
permission
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Authorize egress (outbound) traffic for a VPC security group.
|
201
|
+
#
|
202
|
+
# # allow traffic for all protocols/ports from the given sources
|
203
|
+
# security_group.authorize_egress('10.0.0.0/16', '10.0.0.1/16')
|
204
|
+
#
|
205
|
+
# # allow tcp traffic outband via port 80
|
206
|
+
# security_group.authorize_egress('10.0.0.0/16',
|
207
|
+
# :protocol => :tcp, :ports => 80..80)
|
208
|
+
#
|
209
|
+
# @note Calling this method on a non-VPC security group raises an error.
|
210
|
+
#
|
211
|
+
# @overload authorize_egress(*sources, options = {})
|
212
|
+
# @param [Mixed] sources One or more CIDR IP addresses,
|
213
|
+
# security groups, or hashes. Hash values should
|
214
|
+
# have :group_id and :user_id keys/values. This is useful
|
215
|
+
# for when the security group belongs to another account. The
|
216
|
+
# user id should be the owner_id (account id) of the security
|
217
|
+
# group.
|
218
|
+
# @param [Hash] options
|
219
|
+
# @option options [Symbol] :protocol (:any) The protocol to authorize
|
220
|
+
# traffic for. If this option is ommitted, all protocols are
|
221
|
+
# allowed. Defaults to the symbol +:any+. For a complete list of
|
222
|
+
# supported protocols, see
|
223
|
+
# @option options [Range<Integer>,Integer] :ports (nil) An optional
|
224
|
+
# port or range of ports. This option is required depending on
|
225
|
+
# the protocal.
|
226
|
+
#
|
227
|
+
# @param
|
228
|
+
# @return [IpPermission] Returns an IpPermission object that was added
|
229
|
+
# to this security group.
|
230
|
+
def authorize_egress *args
|
231
|
+
parse_egress_args(*args) do |protocol, ports, options|
|
232
|
+
permission = IpPermission.new(self, protocol, ports, options)
|
233
|
+
permission.authorize
|
234
|
+
permission
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
# Revokes an egress (outound) ip permission. This is the inverse
|
239
|
+
# operation to {#authorize_egress}. See {#authorize_egress}
|
240
|
+
# for param and option documentation.
|
241
|
+
# @see #authorize_egress
|
242
|
+
# @return [IpPermission] Returns an IpPermission object that was added
|
243
|
+
# to this security group.
|
244
|
+
def revoke_egress *args
|
245
|
+
parse_egress_args(*args) do |protocol, ports, options|
|
246
|
+
permission = IpPermission.new(self, protocol, ports, options)
|
247
|
+
permission.revoke
|
248
|
+
permission
|
249
|
+
end
|
162
250
|
end
|
163
251
|
|
164
252
|
# Deletes this security group.
|
@@ -193,58 +281,102 @@ module AWS
|
|
193
281
|
|
194
282
|
# @private
|
195
283
|
protected
|
196
|
-
def
|
197
|
-
|
284
|
+
def parse_ingress_sources sources
|
285
|
+
|
286
|
+
ips, groups = parse_sources(sources)
|
287
|
+
|
288
|
+
options = {}
|
289
|
+
options[:ip_ranges] = ips unless ips.empty?
|
290
|
+
options[:groups] = groups unless groups.empty?
|
291
|
+
options[:egress] = false
|
292
|
+
|
293
|
+
yield(options)
|
294
|
+
|
198
295
|
end
|
199
296
|
|
200
297
|
# @private
|
201
298
|
protected
|
202
|
-
def
|
299
|
+
def parse_egress_args *args, &block
|
300
|
+
ensure_vpc do
|
301
|
+
|
302
|
+
last = args.last
|
303
|
+
|
304
|
+
if last.is_a?(Hash) and (last.key?(:protocol) or last.key?(:ports))
|
305
|
+
# hashes at the end of egress methods could be a hash intedned
|
306
|
+
# to be a source, like:
|
307
|
+
#
|
308
|
+
# { :group_id => ..., :user_id => ... }
|
309
|
+
#
|
310
|
+
options = args.pop
|
311
|
+
else
|
312
|
+
options = {}
|
313
|
+
end
|
203
314
|
|
204
|
-
|
205
|
-
permission[:ip_protocol] = protocol.to_s.downcase
|
206
|
-
permission[:from_port] = Array(ports).first.to_i
|
207
|
-
permission[:to_port] = Array(ports).last.to_i
|
315
|
+
protocol = options[:protocol] || :any
|
208
316
|
|
209
|
-
|
210
|
-
groups = []
|
317
|
+
ports = options[:ports]
|
211
318
|
|
212
|
-
|
213
|
-
|
319
|
+
ips, groups = parse_sources(args)
|
320
|
+
|
321
|
+
options[:ip_ranges] = ips unless ips.empty?
|
322
|
+
options[:groups] = groups unless groups.empty?
|
323
|
+
options[:egress] = true
|
324
|
+
|
325
|
+
yield(protocol, ports, options)
|
326
|
+
|
327
|
+
end
|
328
|
+
end
|
214
329
|
|
215
|
-
|
216
|
-
|
330
|
+
# @private
|
331
|
+
protected
|
332
|
+
def parse_sources sources
|
333
|
+
|
334
|
+
ips = []
|
335
|
+
groups = []
|
336
|
+
|
337
|
+
sources.each do |source|
|
338
|
+
case source
|
339
|
+
when String then ips << source
|
340
|
+
when SecurityGroup then groups << source
|
341
|
+
when Hash
|
342
|
+
if source.has_key?(:group_id) and source.has_key?(:user_id)
|
217
343
|
|
218
|
-
|
219
|
-
|
344
|
+
group = SecurityGroup.new(source[:group_id],
|
345
|
+
:owner_id => source[:user_id],
|
346
|
+
:config => config)
|
220
347
|
|
221
|
-
|
222
|
-
groups << {:group_id => where.id, :user_id => where.owner_id}
|
348
|
+
groups << group
|
223
349
|
|
224
|
-
when Hash
|
225
|
-
if where.has_key?(:group_id) and where.has_key?(:user_id)
|
226
|
-
groups << where
|
227
350
|
else
|
228
|
-
raise ArgumentError, 'invalid
|
229
|
-
|
351
|
+
raise ArgumentError, 'invalid ip permission hash, ' +
|
352
|
+
'must provide :group_id and :user_id'
|
230
353
|
end
|
354
|
+
|
231
355
|
else
|
232
356
|
raise ArgumentError, 'invalid ingress ip permission, ' +
|
233
357
|
'expected CIDR IP addres or SecurityGroup'
|
234
358
|
end
|
235
359
|
end
|
236
360
|
|
237
|
-
|
238
|
-
permission[:ip_ranges] = ip_ranges.collect{|ip| { :cidr_ip => ip } }
|
239
|
-
end
|
361
|
+
ips << '0.0.0.0/0' if ips.empty? and groups.empty?
|
240
362
|
|
241
|
-
|
242
|
-
|
243
|
-
|
363
|
+
[ips, groups]
|
364
|
+
|
365
|
+
end
|
244
366
|
|
245
|
-
|
367
|
+
# @private
|
368
|
+
protected
|
369
|
+
def ensure_vpc &block
|
370
|
+
raise 'operation permitted for VPC security groups only' unless vpc?
|
371
|
+
yield
|
372
|
+
end
|
246
373
|
|
374
|
+
# @private
|
375
|
+
protected
|
376
|
+
def find_in_response(resp)
|
377
|
+
resp.security_group_index[id]
|
247
378
|
end
|
379
|
+
|
248
380
|
end
|
249
381
|
end
|
250
382
|
end
|