fog-aws 3.14.0 → 3.33.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.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -1161
  3. data/README.md +17 -3
  4. data/fog-aws.gemspec +7 -4
  5. data/lib/fog/aws/auto_scaling.rb +1 -1
  6. data/lib/fog/aws/beanstalk.rb +1 -1
  7. data/lib/fog/aws/cdn.rb +1 -1
  8. data/lib/fog/aws/cloud_formation.rb +1 -1
  9. data/lib/fog/aws/cloud_watch.rb +1 -1
  10. data/lib/fog/aws/compute.rb +1 -1
  11. data/lib/fog/aws/credential_fetcher.rb +16 -2
  12. data/lib/fog/aws/data_pipeline.rb +1 -1
  13. data/lib/fog/aws/dns.rb +1 -1
  14. data/lib/fog/aws/dynamodb.rb +1 -1
  15. data/lib/fog/aws/ecs.rb +1 -1
  16. data/lib/fog/aws/elasticache.rb +2 -2
  17. data/lib/fog/aws/elb.rb +1 -1
  18. data/lib/fog/aws/elbv2.rb +1 -1
  19. data/lib/fog/aws/emr.rb +1 -1
  20. data/lib/fog/aws/glacier.rb +1 -1
  21. data/lib/fog/aws/iam.rb +1 -1
  22. data/lib/fog/aws/kinesis.rb +1 -1
  23. data/lib/fog/aws/kms.rb +6 -2
  24. data/lib/fog/aws/lambda.rb +1 -1
  25. data/lib/fog/aws/models/compute/dhcp_option.rb +1 -1
  26. data/lib/fog/aws/models/compute/flavors.rb +2144 -754
  27. data/lib/fog/aws/models/compute/network_interfaces.rb +1 -1
  28. data/lib/fog/aws/models/elasticache/cluster.rb +1 -1
  29. data/lib/fog/aws/models/storage/file.rb +26 -10
  30. data/lib/fog/aws/models/storage/files.rb +3 -2
  31. data/lib/fog/aws/parsers/compute/describe_instance_status.rb +5 -3
  32. data/lib/fog/aws/parsers/iam/get_group_policy.rb +1 -1
  33. data/lib/fog/aws/parsers/iam/get_role_policy.rb +1 -1
  34. data/lib/fog/aws/parsers/iam/get_user_policy.rb +1 -1
  35. data/lib/fog/aws/parsers/iam/list_server_certificates.rb +1 -1
  36. data/lib/fog/aws/parsers/iam/policy_version.rb +1 -1
  37. data/lib/fog/aws/parsers/kms/describe_key.rb +2 -2
  38. data/lib/fog/aws/parsers/kms/get_public_key.rb +30 -0
  39. data/lib/fog/aws/parsers/kms/schedule_key_deletion.rb +28 -0
  40. data/lib/fog/aws/parsers/kms/sign.rb +24 -0
  41. data/lib/fog/aws/parsers/rds/db_cluster_parser.rb +1 -1
  42. data/lib/fog/aws/parsers/rds/db_parser.rb +1 -1
  43. data/lib/fog/aws/parsers/rds/modify_db_subnet_group.rb +1 -1
  44. data/lib/fog/aws/parsers/redshift/cluster_subnet_group_parser.rb +1 -1
  45. data/lib/fog/aws/parsers/storage/list_objects_v2.rb +66 -0
  46. data/lib/fog/aws/rds.rb +1 -1
  47. data/lib/fog/aws/redshift.rb +1 -1
  48. data/lib/fog/aws/requests/auto_scaling/attach_load_balancer_target_groups.rb +1 -1
  49. data/lib/fog/aws/requests/auto_scaling/describe_scaling_activities.rb +1 -1
  50. data/lib/fog/aws/requests/auto_scaling/put_scheduled_update_group_action.rb +1 -1
  51. data/lib/fog/aws/requests/cloud_formation/create_change_set.rb +1 -1
  52. data/lib/fog/aws/requests/cloud_formation/create_stack.rb +1 -1
  53. data/lib/fog/aws/requests/cloud_formation/get_template_summary.rb +1 -1
  54. data/lib/fog/aws/requests/cloud_formation/update_stack.rb +1 -1
  55. data/lib/fog/aws/requests/cloud_watch/list_metrics.rb +1 -1
  56. data/lib/fog/aws/requests/compute/authorize_security_group_egress.rb +1 -1
  57. data/lib/fog/aws/requests/compute/authorize_security_group_ingress.rb +1 -1
  58. data/lib/fog/aws/requests/compute/create_network_interface.rb +1 -1
  59. data/lib/fog/aws/requests/compute/create_vpc.rb +1 -1
  60. data/lib/fog/aws/requests/compute/describe_network_interfaces.rb +2 -2
  61. data/lib/fog/aws/requests/compute/modify_network_interface_attribute.rb +1 -1
  62. data/lib/fog/aws/requests/compute/modify_volume.rb +1 -1
  63. data/lib/fog/aws/requests/compute/revoke_security_group_egress.rb +1 -1
  64. data/lib/fog/aws/requests/compute/revoke_security_group_ingress.rb +1 -1
  65. data/lib/fog/aws/requests/compute/run_instances.rb +2 -2
  66. data/lib/fog/aws/requests/data_pipeline/deactivate_pipeline.rb +1 -1
  67. data/lib/fog/aws/requests/ecs/list_task_definitions.rb +1 -1
  68. data/lib/fog/aws/requests/efs/create_file_system.rb +1 -1
  69. data/lib/fog/aws/requests/elasticache/authorize_cache_security_group_ingress.rb +1 -1
  70. data/lib/fog/aws/requests/elasticache/create_cache_cluster.rb +2 -2
  71. data/lib/fog/aws/requests/elasticache/describe_engine_default_parameters.rb +1 -1
  72. data/lib/fog/aws/requests/elb/delete_load_balancer_listeners.rb +1 -1
  73. data/lib/fog/aws/requests/elbv2/describe_tags.rb +2 -2
  74. data/lib/fog/aws/requests/glacier/initiate_job.rb +1 -1
  75. data/lib/fog/aws/requests/glacier/initiate_multipart_upload.rb +1 -1
  76. data/lib/fog/aws/requests/kinesis/list_streams.rb +1 -1
  77. data/lib/fog/aws/requests/kms/create_key.rb +74 -36
  78. data/lib/fog/aws/requests/kms/get_public_key.rb +35 -0
  79. data/lib/fog/aws/requests/kms/list_keys.rb +3 -4
  80. data/lib/fog/aws/requests/kms/schedule_key_deletion.rb +37 -0
  81. data/lib/fog/aws/requests/kms/sign.rb +62 -0
  82. data/lib/fog/aws/requests/rds/authorize_db_security_group_ingress.rb +2 -2
  83. data/lib/fog/aws/requests/rds/create_db_cluster.rb +1 -1
  84. data/lib/fog/aws/requests/rds/describe_db_snapshots.rb +1 -1
  85. data/lib/fog/aws/requests/rds/modify_db_instance.rb +1 -1
  86. data/lib/fog/aws/requests/rds/modify_db_parameter_group.rb +1 -1
  87. data/lib/fog/aws/requests/ses/send_raw_email.rb +1 -1
  88. data/lib/fog/aws/requests/sqs/change_message_visibility.rb +1 -1
  89. data/lib/fog/aws/requests/sqs/delete_message.rb +1 -1
  90. data/lib/fog/aws/requests/storage/copy_object.rb +2 -1
  91. data/lib/fog/aws/requests/storage/get_bucket.rb +2 -2
  92. data/lib/fog/aws/requests/storage/get_bucket_object_versions.rb +2 -2
  93. data/lib/fog/aws/requests/storage/get_service.rb +1 -1
  94. data/lib/fog/aws/requests/storage/list_objects_v2.rb +129 -0
  95. data/lib/fog/aws/requests/storage/list_parts.rb +1 -1
  96. data/lib/fog/aws/requests/storage/post_object_restore.rb +24 -4
  97. data/lib/fog/aws/requests/storage/put_bucket.rb +0 -4
  98. data/lib/fog/aws/requests/storage/put_bucket_lifecycle.rb +1 -1
  99. data/lib/fog/aws/requests/storage/put_bucket_notification.rb +1 -1
  100. data/lib/fog/aws/requests/storage/put_object.rb +1 -1
  101. data/lib/fog/aws/requests/storage/sync_clock.rb +9 -1
  102. data/lib/fog/aws/requests/storage/upload_part_copy.rb +1 -1
  103. data/lib/fog/aws/ses.rb +20 -17
  104. data/lib/fog/aws/signaturev4.rb +1 -1
  105. data/lib/fog/aws/simpledb.rb +1 -1
  106. data/lib/fog/aws/sns.rb +1 -1
  107. data/lib/fog/aws/sqs.rb +1 -1
  108. data/lib/fog/aws/storage.rb +38 -9
  109. data/lib/fog/aws/support.rb +1 -1
  110. data/lib/fog/aws/version.rb +1 -1
  111. data/lib/fog/aws.rb +6 -3
  112. metadata +37 -11
@@ -0,0 +1,129 @@
1
+ module Fog
2
+ module AWS
3
+ class Storage
4
+ class Real
5
+ require 'fog/aws/parsers/storage/list_objects_v2'
6
+
7
+ # List information about objects in an S3 bucket using ListObjectsV2
8
+ #
9
+ # @param bucket_name [String] name of bucket to list object keys from
10
+ # @param options [Hash] config arguments for list. Defaults to {}.
11
+ # @option options delimiter [String] causes keys with the same string between the prefix
12
+ # value and the first occurrence of delimiter to be rolled up
13
+ # @option options continuation-token [String] continuation token from a previous request
14
+ # @option options fetch-owner [Boolean] specifies whether to return owner information
15
+ # @option options max-keys [Integer] limits number of object keys returned
16
+ # @option options prefix [String] limits object keys to those beginning with its value
17
+ # @option options start-after [String] starts listing after this specified key
18
+ #
19
+ # @return [Excon::Response] response:
20
+ # * body [Hash]:
21
+ # * Delimiter [String] - Delimiter specified for query
22
+ # * IsTruncated [Boolean] - Whether or not the listing is truncated
23
+ # * ContinuationToken [String] - Token specified in the request
24
+ # * NextContinuationToken [String] - Token to use in subsequent requests
25
+ # * KeyCount [Integer] - Number of keys returned
26
+ # * MaxKeys [Integer] - Maximum number of keys specified for query
27
+ # * Name [String] - Name of the bucket
28
+ # * Prefix [String] - Prefix specified for query
29
+ # * StartAfter [String] - StartAfter specified in the request
30
+ # * CommonPrefixes [Array] - Array of strings for common prefixes
31
+ # * Contents [Array]:
32
+ # * ETag [String] - Etag of object
33
+ # * Key [String] - Name of object
34
+ # * LastModified [String] - Timestamp of last modification of object
35
+ # * Owner [Hash]:
36
+ # * DisplayName [String] - Display name of object owner
37
+ # * ID [String] - Id of object owner
38
+ # * Size [Integer] - Size of object
39
+ # * StorageClass [String] - Storage class of object
40
+ #
41
+ # @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
42
+
43
+ def list_objects_v2(bucket_name, options = {})
44
+ unless bucket_name
45
+ raise ArgumentError.new('bucket_name is required')
46
+ end
47
+
48
+ # Add list-type=2 to indicate ListObjectsV2
49
+ options = options.merge('list-type' => '2')
50
+
51
+ request({
52
+ :expects => 200,
53
+ :headers => {},
54
+ :bucket_name => bucket_name,
55
+ :idempotent => true,
56
+ :method => 'GET',
57
+ :parser => Fog::Parsers::AWS::Storage::ListObjectsV2.new,
58
+ :query => options
59
+ })
60
+ end
61
+ end
62
+
63
+ class Mock # :nodoc:all
64
+ def list_objects_v2(bucket_name, options = {})
65
+ prefix = options['prefix']
66
+ continuation_token = options['continuation-token']
67
+ delimiter = options['delimiter']
68
+ max_keys = options['max-keys']
69
+ start_after = options['start-after']
70
+ fetch_owner = options['fetch-owner']
71
+ common_prefixes = []
72
+
73
+ unless bucket_name
74
+ raise ArgumentError.new('bucket_name is required')
75
+ end
76
+
77
+ response = Excon::Response.new
78
+ if bucket = self.data[:buckets][bucket_name]
79
+ contents = bucket[:objects].values.map(&:first).sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
80
+ (prefix && object['Key'][0...prefix.length] != prefix) ||
81
+ (start_after && object['Key'] <= start_after) ||
82
+ (continuation_token && object['Key'] <= continuation_token) ||
83
+ (delimiter && object['Key'][(prefix ? prefix.length : 0)..-1].include?(delimiter) \
84
+ && common_prefixes << object['Key'].sub(/^(#{prefix}[^#{delimiter}]+.).*/, '\1')) ||
85
+ object.key?(:delete_marker)
86
+ end.map do |object|
87
+ data = object.reject {|key, value| !['ETag', 'Key', 'StorageClass'].include?(key)}
88
+ data.merge!({
89
+ 'LastModified' => Time.parse(object['Last-Modified']),
90
+ 'Owner' => fetch_owner ? bucket['Owner'] : nil,
91
+ 'Size' => object['Content-Length'].to_i
92
+ })
93
+ data
94
+ end
95
+
96
+ max_keys = max_keys || 1000
97
+ size = [max_keys, 1000].min
98
+ truncated_contents = contents[0...size]
99
+ next_token = truncated_contents.size != contents.size ? truncated_contents.last['Key'] : nil
100
+
101
+ response.status = 200
102
+ common_prefixes_uniq = common_prefixes.uniq
103
+ response.body = {
104
+ 'CommonPrefixes' => common_prefixes_uniq,
105
+ 'Contents' => truncated_contents,
106
+ 'IsTruncated' => truncated_contents.size != contents.size,
107
+ 'ContinuationToken' => continuation_token,
108
+ 'NextContinuationToken' => next_token,
109
+ 'KeyCount' => truncated_contents.size + common_prefixes_uniq.size,
110
+ 'MaxKeys' => max_keys,
111
+ 'Name' => bucket['Name'],
112
+ 'Prefix' => prefix,
113
+ 'StartAfter' => start_after
114
+ }
115
+ if max_keys && max_keys < response.body['Contents'].length
116
+ response.body['IsTruncated'] = true
117
+ response.body['Contents'] = response.body['Contents'][0...max_keys]
118
+ response.body['KeyCount'] = response.body['Contents'].size + response.body['CommonPrefixes'].size
119
+ end
120
+ else
121
+ response.status = 404
122
+ raise(Excon::Errors.status_error({:expects => 200}, response))
123
+ end
124
+ response
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -21,7 +21,7 @@ module Fog
21
21
  # * ID [String] Id of upload initiator
22
22
  # * IsTruncated [Boolean] Whether or not the listing is truncated
23
23
  # * Key [String] Key where multipart upload was initiated
24
- # * MaxParts [String] maximum number of replies alllowed in response
24
+ # * MaxParts [String] maximum number of replies allowed in response
25
25
  # * NextPartNumberMarker [String] last item in list, for further pagination
26
26
  # * Part [Array]:
27
27
  # * ETag [String] ETag of part
@@ -6,7 +6,9 @@ module Fog
6
6
  #
7
7
  # @param bucket_name [String] Name of bucket containing object
8
8
  # @param object_name [String] Name of object to restore
9
- # @option days [Integer] Number of days to restore object for. Defaults to 100000 (a very long time)
9
+ # @param options [Hash] Optional parameters
10
+ # @option options [Integer] :days Number of days to restore object for. Defaults to 100000 (a very long time)
11
+ # @option options [String] :tier Glacier retrieval tier. Can be 'Standard', 'Bulk', or 'Expedited'
10
12
  #
11
13
  # @return [Excon::Response] response:
12
14
  # * status [Integer] 200 (OK) Object is previously restored
@@ -15,11 +17,24 @@ module Fog
15
17
  #
16
18
  # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPOSTrestore.html
17
19
  #
18
- def post_object_restore(bucket_name, object_name, days = 100000)
20
+ def post_object_restore(bucket_name, object_name, options = {})
19
21
  raise ArgumentError.new('bucket_name is required') unless bucket_name
20
22
  raise ArgumentError.new('object_name is required') unless object_name
21
23
 
22
- data = '<RestoreRequest xmlns="http://s3.amazonaws.com/doc/2006-3-01"><Days>' + days.to_s + '</Days></RestoreRequest>'
24
+ unless options.is_a?(Hash)
25
+ Fog::Logger.deprecation("post_object_restore with a bare days parameter is deprecated, use post_object_restore(bucket_name, object_name, :days => days) instead [light_black](#{caller.first})[/]")
26
+ options = { :days => options }
27
+ end
28
+
29
+ days = options[:days] || 100000
30
+ tier = options[:tier]
31
+
32
+ data = '<RestoreRequest xmlns="http://s3.amazonaws.com/doc/2006-03-01/">'
33
+ data += '<Days>' + days.to_s + '</Days>'
34
+ if tier
35
+ data += '<GlacierJobParameters><Tier>' + tier + '</Tier></GlacierJobParameters>'
36
+ end
37
+ data += '</RestoreRequest>'
23
38
 
24
39
  headers = {}
25
40
  headers['Content-MD5'] = Base64.encode64(OpenSSL::Digest::MD5.digest(data)).strip
@@ -39,7 +54,12 @@ module Fog
39
54
  end
40
55
 
41
56
  class Mock # :nodoc:all
42
- def post_object_restore(bucket_name, object_name, days = 100000)
57
+ def post_object_restore(bucket_name, object_name, options = {})
58
+ unless options.is_a?(Hash)
59
+ Fog::Logger.deprecation("post_object_restore with a bare days parameter is deprecated, use post_object_restore(bucket_name, object_name, :days => days) instead [light_black](#{caller.first})[/]")
60
+ options = { :days => options }
61
+ end
62
+
43
63
  response = get_object(bucket_name, object_name)
44
64
  response.body = nil
45
65
  response
@@ -61,10 +61,6 @@ DATA
61
61
  end
62
62
  if !self.data[:buckets][bucket_name]
63
63
  self.data[:buckets][bucket_name] = bucket
64
- elsif self.region != 'us-east-1'
65
- response.status = 409
66
- Fog::Logger.warning "Your region '#{self.region}' does not match the default region 'us-east-1'"
67
- raise(Excon::Errors.status_error({:expects => 201}, response))
68
64
  end
69
65
  response
70
66
  end
@@ -47,7 +47,7 @@ module Fog
47
47
  if rule['NoncurrentVersionExpiration']['NoncurrentDays']
48
48
  NoncurrentVersionExpiration { NoncurrentDays rule['NoncurrentVersionExpiration']['NoncurrentDays'] }
49
49
  elsif rule['NoncurrentVersionExpiration']['Date']
50
- NoncurrentVersoinExpiration {
50
+ NoncurrentVersionExpiration {
51
51
  if Date rule['NoncurrentVersionExpiration']['Date'].is_a?(Time)
52
52
  rule['NoncurrentVersionExpiration']['Date'].utc.iso8601
53
53
  else
@@ -5,7 +5,7 @@ module Fog
5
5
  # Change notification configuration for an S3 bucket
6
6
  #
7
7
  # @param bucket_name [String] name of bucket to set notification configuration for
8
- # * notications [Hash]:
8
+ # * notifications [Hash]:
9
9
  # * Topics [Array] SNS topic configurations for the notification
10
10
  # * ID [String] Unique identifier for the configuration
11
11
  # * Topic [String] Amazon SNS topic ARN to which Amazon S3 will publish a message when it detects events of specified type
@@ -16,7 +16,7 @@ module Fog
16
16
  # @option options Content-Type [String] Standard MIME type describing contents (defaults to MIME::Types.of.first)
17
17
  # @option options Expires [String] Cache expiry
18
18
  # @option options x-amz-acl [String] Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']
19
- # @option options x-amz-storage-class [String] Default is 'STANDARD', set to 'REDUCED_REDUNDANCY' for non-critical, reproducable data
19
+ # @option options x-amz-storage-class [String] Default is 'STANDARD', set to 'REDUCED_REDUNDANCY' for non-critical, reproducible data
20
20
  # @option options x-amz-meta-#{name} Headers to be returned with object, note total size of request without body must be less than 8 KB. Each name, value pair must conform to US-ASCII.
21
21
  # @option options x-amz-server-side-encryption [String] Sets HTTP header for server-side encryption. Set to 'AES256' for SSE-S3 and SSE-C. Set to 'aws:kms' for SSE-KMS
22
22
  # @option options x-amz-server-side​-encryption​-customer-algorithm [String] Algorithm to use to when encrypting the object for SSE-C.
@@ -6,12 +6,20 @@ module Fog
6
6
  #
7
7
  def sync_clock
8
8
  response = begin
9
- get_service
9
+ Excon.get(sync_clock_url)
10
10
  rescue Excon::Errors::HTTPStatusError => error
11
11
  error.response
12
12
  end
13
13
  Fog::Time.now = Time.parse(response.headers['Date'])
14
14
  end
15
+
16
+ private
17
+
18
+ def sync_clock_url
19
+ host = @acceleration ? region_to_host(@region) : @host
20
+
21
+ "#{@scheme}://#{host}:#{@port}"
22
+ end
15
23
  end # Real
16
24
 
17
25
  class Mock # :nodoc:all
@@ -35,7 +35,7 @@ module Fog
35
35
  # @option options [Time] x-amz-copy_source-if-modified_since Copies object it it has been modified since this time
36
36
  # @option options [String] x-amz-copy_source-if-none-match Copies object if its etag does not match this value
37
37
  # @option options [Time] x-amz-copy_source-if-unmodified-since Copies object it it has not been modified since this time
38
- # @option options [Time] x-amz-copy-source-range Specifes the range of bytes to copy from the source object
38
+ # @option options [Time] x-amz-copy-source-range Specifies the range of bytes to copy from the source object
39
39
  #
40
40
  # @return [Excon::Response]
41
41
  # * body [Hash]:
data/lib/fog/aws/ses.rb CHANGED
@@ -7,7 +7,7 @@ module Fog
7
7
  class MessageRejected < Fog::Errors::Error; end
8
8
 
9
9
  requires :aws_access_key_id, :aws_secret_access_key
10
- recognizes :region, :host, :path, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :instrumentor, :instrumentor_name
10
+ recognizes :region, :host, :path, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :instrumentor, :instrumentor_name, :sts_endpoint
11
11
 
12
12
  request_path 'fog/aws/requests/ses'
13
13
  request :delete_verified_email_address
@@ -48,18 +48,21 @@ module Fog
48
48
  def initialize(options={})
49
49
 
50
50
  @use_iam_profile = options[:use_iam_profile]
51
- setup_credentials(options)
52
51
 
53
52
  @instrumentor = options[:instrumentor]
54
53
  @instrumentor_name = options[:instrumentor_name] || 'fog.aws.ses'
55
54
  @connection_options = options[:connection_options] || {}
56
55
  options[:region] ||= 'us-east-1'
56
+ @region = options[:region]
57
+
57
58
  @host = options[:host] || "email.#{options[:region]}.amazonaws.com"
58
59
  @path = options[:path] || '/'
59
60
  @persistent = options[:persistent] || false
60
61
  @port = options[:port] || 443
61
62
  @scheme = options[:scheme] || 'https'
62
63
  @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
64
+
65
+ setup_credentials(options)
63
66
  end
64
67
 
65
68
  def reload
@@ -74,7 +77,7 @@ module Fog
74
77
  @aws_session_token = options[:aws_session_token]
75
78
  @aws_credentials_expire_at = options[:aws_credentials_expire_at]
76
79
 
77
- @hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
80
+ @signer = Fog::AWS::SignatureV4.new(@aws_access_key_id, @aws_secret_access_key, @region, 'ses')
78
81
  end
79
82
 
80
83
  def request(params)
@@ -87,20 +90,20 @@ module Fog
87
90
  'Content-Type' => 'application/x-www-form-urlencoded',
88
91
  'Date' => Fog::Time.now.to_date_header,
89
92
  }
90
- headers['x-amz-security-token'] = @aws_session_token if @aws_session_token
91
- #AWS3-HTTPS AWSAccessKeyId=<Your AWS Access Key ID>, Algorithm=HmacSHA256, Signature=<Signature>
92
- headers['X-Amzn-Authorization'] = 'AWS3-HTTPS '
93
- headers['X-Amzn-Authorization'] << 'AWSAccessKeyId=' << @aws_access_key_id
94
- headers['X-Amzn-Authorization'] << ', Algorithm=HmacSHA256'
95
- headers['X-Amzn-Authorization'] << ', Signature=' << Base64.encode64(@hmac.sign(headers['Date'])).chomp!
96
-
97
- body = ''
98
- for key in params.keys.sort
99
- unless (value = params[key]).nil?
100
- body << "#{key}=#{CGI.escape(value.to_s).gsub(/\+/, '%20')}&"
101
- end
102
- end
103
- body.chop! # remove trailing '&'
93
+
94
+ body, headers = AWS.signed_params_v4(
95
+ params,
96
+ { 'Content-Type' => 'application/x-www-form-urlencoded' },
97
+ {
98
+ :method => 'POST',
99
+ :aws_session_token => @aws_session_token,
100
+ :signer => @signer,
101
+ :host => @host,
102
+ :path => @path,
103
+ :port => @port,
104
+ :version => '2010-12-01'
105
+ }
106
+ )
104
107
 
105
108
  if @instrumentor
106
109
  @instrumentor.instrument("#{@instrumentor_name}.request", params) do
@@ -106,7 +106,7 @@ DATA
106
106
  end
107
107
 
108
108
  def canonical_headers(headers)
109
- canonical_headers = ''
109
+ canonical_headers = +''
110
110
 
111
111
  for key in headers.keys.sort_by {|k| k.to_s.downcase}
112
112
  canonical_headers << "#{key.to_s.downcase}:#{headers[key].to_s.strip}\n"
@@ -4,7 +4,7 @@ module Fog
4
4
  extend Fog::AWS::CredentialFetcher::ServiceMethods
5
5
 
6
6
  requires :aws_access_key_id, :aws_secret_access_key
7
- recognizes :host, :nil_string, :path, :port, :scheme, :persistent, :region, :aws_session_token, :use_iam_profile, :aws_credentials_expire_at, :instrumentor, :instrumentor_name
7
+ recognizes :host, :nil_string, :path, :port, :scheme, :persistent, :region, :aws_session_token, :use_iam_profile, :aws_credentials_expire_at, :instrumentor, :instrumentor_name, :sts_endpoint
8
8
 
9
9
  request_path 'fog/aws/requests/simpledb'
10
10
  request :batch_put_attributes
data/lib/fog/aws/sns.rb CHANGED
@@ -4,7 +4,7 @@ module Fog
4
4
  extend Fog::AWS::CredentialFetcher::ServiceMethods
5
5
 
6
6
  requires :aws_access_key_id, :aws_secret_access_key
7
- recognizes :host, :path, :port, :scheme, :persistent, :region, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :instrumentor, :instrumentor_name
7
+ recognizes :host, :path, :port, :scheme, :persistent, :region, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :instrumentor, :instrumentor_name, :sts_endpoint
8
8
 
9
9
  request_path 'fog/aws/requests/sns'
10
10
  request :add_permission
data/lib/fog/aws/sqs.rb CHANGED
@@ -4,7 +4,7 @@ module Fog
4
4
  extend Fog::AWS::CredentialFetcher::ServiceMethods
5
5
 
6
6
  requires :aws_access_key_id, :aws_secret_access_key
7
- recognizes :region, :host, :path, :port, :scheme, :persistent, :aws_session_token, :use_iam_profile, :aws_credentials_expire_at, :instrumentor, :instrumentor_name
7
+ recognizes :region, :host, :path, :port, :scheme, :persistent, :aws_session_token, :use_iam_profile, :aws_credentials_expire_at, :instrumentor, :instrumentor_name, :sts_endpoint
8
8
 
9
9
  request_path 'fog/aws/requests/sqs'
10
10
  request :change_message_visibility
@@ -7,6 +7,8 @@ module Fog
7
7
 
8
8
  DEFAULT_REGION = 'us-east-1'
9
9
  ACCELERATION_HOST = 's3-accelerate.amazonaws.com'
10
+ AWS_FIPS_REGIONS = %w(us-east-1 us-east-2 us-west-1 us-west-2 us-gov-east-1 us-gov-west-1 ca-central-1 ca-west-1).freeze
11
+ AWS_GOVCLOUD_REGIONS = %w(us-gov-east-1 us-gov-west-1).freeze
10
12
 
11
13
  DEFAULT_SCHEME = 'https'
12
14
  DEFAULT_SCHEME_PORT = {
@@ -14,14 +16,22 @@ module Fog
14
16
  'https' => 443
15
17
  }
16
18
 
19
+ DEFAULT_CONNECTION_OPTIONS = {
20
+ retry_limit: 5,
21
+ retry_interval: 1
22
+ }
23
+
17
24
  MIN_MULTIPART_CHUNK_SIZE = 5242880
18
25
  MAX_SINGLE_PUT_SIZE = 5368709120
19
26
 
20
27
  VALID_QUERY_KEYS = %w[
21
28
  acl
29
+ continuation-token
22
30
  cors
23
31
  delete
32
+ fetch-owner
24
33
  lifecycle
34
+ list-type
25
35
  location
26
36
  logging
27
37
  notification
@@ -35,6 +45,7 @@ module Fog
35
45
  response-content-type
36
46
  response-expires
37
47
  restore
48
+ start-after
38
49
  tagging
39
50
  torrent
40
51
  uploadId
@@ -46,7 +57,7 @@ module Fog
46
57
  ]
47
58
 
48
59
  requires :aws_access_key_id, :aws_secret_access_key
49
- recognizes :endpoint, :region, :host, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :path_style, :acceleration, :instrumentor, :instrumentor_name, :aws_signature_version, :enable_signature_v4_streaming, :virtual_host, :cname, :max_put_chunk_size, :max_copy_chunk_size, :aws_credentials_refresh_threshold_seconds
60
+ recognizes :endpoint, :region, :host, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :path_style, :acceleration, :instrumentor, :instrumentor_name, :aws_signature_version, :enable_signature_v4_streaming, :virtual_host, :cname, :max_put_chunk_size, :max_copy_chunk_size, :aws_credentials_refresh_threshold_seconds, :disable_content_md5_validation, :sts_endpoint
50
61
 
51
62
  secrets :aws_secret_access_key, :hmac
52
63
 
@@ -95,6 +106,7 @@ module Fog
95
106
  request :head_object_url
96
107
  request :initiate_multipart_upload
97
108
  request :list_multipart_uploads
109
+ request :list_objects_v2
98
110
  request :list_parts
99
111
  request :post_object_hidden_fields
100
112
  request :post_object_restore
@@ -119,6 +131,7 @@ module Fog
119
131
 
120
132
  module Utils
121
133
  attr_accessor :region
134
+ attr_accessor :disable_content_md5_validation
122
135
 
123
136
  # Amazon S3 limits max chunk size that can be uploaded/copied in a single request to 5GB.
124
137
  # Other S3-compatible storages (like, Ceph) do not have such limit.
@@ -252,13 +265,17 @@ module Fog
252
265
  end
253
266
 
254
267
  def region_to_host(region=nil)
255
- case region.to_s
256
- when DEFAULT_REGION, ''
257
- 's3.amazonaws.com'
258
- when %r{\Acn-.*}
259
- "s3.#{region}.amazonaws.com.cn"
268
+ if ENV['AWS_USE_FIPS_ENDPOINT'] == 'true' && AWS_FIPS_REGIONS.include?(region)
269
+ "s3-fips.#{region}.amazonaws.com" # https://aws.amazon.com/compliance/fips/
260
270
  else
261
- "s3.#{region}.amazonaws.com"
271
+ case region.to_s
272
+ when DEFAULT_REGION, ''
273
+ 's3.amazonaws.com'
274
+ when %r{\Acn-.*}
275
+ "s3.#{region}.amazonaws.com.cn"
276
+ else
277
+ "s3.#{region}.amazonaws.com"
278
+ end
262
279
  end
263
280
  end
264
281
 
@@ -486,6 +503,8 @@ module Fog
486
503
  init_max_put_chunk_size!(options)
487
504
  init_max_copy_chunk_size!(options)
488
505
 
506
+ @disable_content_md5_validation = options[:disable_content_md5_validation] || false
507
+
489
508
  @signature_version = options.fetch(:aws_signature_version, 4)
490
509
  validate_signature_version!
491
510
  setup_credentials(options)
@@ -543,17 +562,20 @@ module Fog
543
562
  @use_iam_profile = options[:use_iam_profile]
544
563
  @instrumentor = options[:instrumentor]
545
564
  @instrumentor_name = options[:instrumentor_name] || 'fog.aws.storage'
546
- @connection_options = options[:connection_options] || {}
565
+ @connection_options =
566
+ DEFAULT_CONNECTION_OPTIONS.merge(options[:connection_options] || {})
547
567
  @persistent = options.fetch(:persistent, false)
548
568
  @acceleration = options.fetch(:acceleration, false)
549
569
  @signature_version = options.fetch(:aws_signature_version, 4)
550
- @enable_signature_v4_streaming = options.fetch(:enable_signature_v4_streaming, true)
570
+ @enable_signature_v4_streaming = options.fetch(:enable_signature_v4_streaming, false)
551
571
  validate_signature_version!
552
572
  @path_style = options[:path_style] || false
553
573
 
554
574
  init_max_put_chunk_size!(options)
555
575
  init_max_copy_chunk_size!(options)
556
576
 
577
+ @disable_content_md5_validation = options[:disable_content_md5_validation] || false
578
+
557
579
  @region = options[:region] || DEFAULT_REGION
558
580
 
559
581
  if @endpoint = options[:endpoint]
@@ -567,6 +589,13 @@ module Fog
567
589
  @port = options[:port] || DEFAULT_SCHEME_PORT[@scheme]
568
590
  end
569
591
 
592
+ # GovCloud doesn't support S3 Transfer Acceleration https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-s3.html
593
+ # S3 Transfer Acceleration doesn't support FIPS endpoints. When both fog_aws_accelerate=true and AWS_USE_FIPS_ENDPOINT=true, don't use Accelerate.
594
+ if @acceleration && (AWS_GOVCLOUD_REGIONS.include?(@region) || ENV['AWS_USE_FIPS_ENDPOINT'] == 'true')
595
+ Fog::Logger.warning("fog: S3 Transfer Acceleration is not available in GovCloud regions or when AWS_USE_FIPS_ENDPOINT=true. Disabling acceleration.")
596
+ @acceleration = false
597
+ end
598
+
570
599
  @host = ACCELERATION_HOST if @acceleration
571
600
  setup_credentials(options)
572
601
  end
@@ -4,7 +4,7 @@ module Fog
4
4
  extend Fog::AWS::CredentialFetcher::ServiceMethods
5
5
 
6
6
  requires :aws_access_key_id, :aws_secret_access_key
7
- recognizes :host, :path, :port, :scheme, :instrumentor, :instrumentor_name, :region, :persistent, :aws_session_token
7
+ recognizes :host, :path, :port, :scheme, :instrumentor, :instrumentor_name, :region, :persistent, :aws_session_token, :aws_credentials_expire_at, :sts_endpoint
8
8
 
9
9
  model_path 'fog/aws/models/support'
10
10
  request_path 'fog/aws/requests/support'
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AWS
3
- VERSION = "3.14.0"
3
+ VERSION = '3.33.0'.freeze
4
4
  end
5
5
  end
data/lib/fog/aws.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'base64'
1
2
  require 'fog/core'
2
3
  require 'fog/xml'
3
4
  require 'fog/json'
@@ -224,14 +225,16 @@ module Fog
224
225
  'ap-east-1',
225
226
  'ap-northeast-1', 'ap-northeast-2', 'ap-northeast-3',
226
227
  'ap-south-1',
227
- 'ap-southeast-1', 'ap-southeast-2',
228
+ 'ap-southeast-1', 'ap-southeast-2', 'ap-southeast-3', 'ap-southeast-4',
228
229
  'ca-central-1',
230
+ 'ca-west-1',
229
231
  'cn-north-1',
230
232
  'cn-northwest-1',
231
233
  'eu-central-1',
232
234
  'eu-north-1',
233
- 'eu-west-1', 'eu-west-2', 'eu-west-3', 'eu-south-1',
234
- 'me-south-1',
235
+ 'eu-west-1', 'eu-west-2', 'eu-west-3', 'eu-south-1', 'eu-south-2',
236
+ 'il-central-1',
237
+ 'me-south-1', 'me-central-1',
235
238
  'us-east-1', 'us-east-2',
236
239
  'us-west-1', 'us-west-2',
237
240
  'sa-east-1',