Skip to content

Commit

Permalink
Remove s3control as a dependency to s3 and use loading approach
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Apr 29, 2024
1 parent eebccc9 commit 5ca578f
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 8 deletions.
4 changes: 1 addition & 3 deletions gems/aws-sdk-s3/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Unreleased Changes
------------------

* Feature - Support S3 Access Grants authentication. Access Grants can be enabled with the `s3_access_grants` option, and custom options can be passed into the `access_grants_credentials_provider` option.

* Feature - S3 now depends on `aws-sdk-s3control` for Access Grants credential fetching.
* Feature - Support S3 Access Grants authentication. Access Grants can be enabled with the `s3_access_grants` option, and custom options can be passed into the `access_grants_credentials_provider` option. This feature is enabled if `aws-sdk-s3control` is installed.

1.148.0 (2024-04-25)
------------------
Expand Down
1 change: 0 additions & 1 deletion gems/aws-sdk-s3/aws-sdk-s3.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
}

spec.add_dependency('aws-sdk-kms', '~> 1')
spec.add_dependency('aws-sdk-s3control', '~> 1.73')
spec.add_dependency('aws-sigv4', '~> 1.8')
spec.add_dependency('aws-sdk-core', '~> 3', '>= 3.194.0')

Expand Down
1 change: 0 additions & 1 deletion gems/aws-sdk-s3/features/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
$:.unshift(File.expand_path('../../lib', __FILE__))
$:.unshift(File.expand_path('../../../aws-sdk-core/features', __FILE__))
$:.unshift(File.expand_path('../../../aws-sdk-kms/lib', __FILE__))
$:.unshift(File.expand_path('../../../aws-sdk-s3control/lib', __FILE__))
$:.unshift(File.expand_path('../../../aws-sigv4/lib', __FILE__))
$:.unshift(File.expand_path('../../../aws-sdk-core/lib', __FILE__))

Expand Down
1 change: 0 additions & 1 deletion gems/aws-sdk-s3/lib/aws-sdk-s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


require 'aws-sdk-kms'
require 'aws-sdk-s3control'
require 'aws-sigv4'
require 'aws-sdk-core'

Expand Down
12 changes: 12 additions & 0 deletions gems/aws-sdk-s3/lib/aws-sdk-s3/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
require 'aws-sdk-core/plugins/sign.rb'
require 'aws-sdk-core/plugins/protocols/rest_xml.rb'
require 'aws-sdk-s3/plugins/accelerate.rb'
require 'aws-sdk-s3/plugins/access_grants.rb'
require 'aws-sdk-s3/plugins/arn.rb'
require 'aws-sdk-s3/plugins/bucket_dns.rb'
require 'aws-sdk-s3/plugins/bucket_name_restrictions.rb'
Expand Down Expand Up @@ -106,6 +107,7 @@ class Client < Seahorse::Client::Base
add_plugin(Aws::Plugins::Sign)
add_plugin(Aws::Plugins::Protocols::RestXml)
add_plugin(Aws::S3::Plugins::Accelerate)
add_plugin(Aws::S3::Plugins::AccessGrants)
add_plugin(Aws::S3::Plugins::ARN)
add_plugin(Aws::S3::Plugins::BucketDns)
add_plugin(Aws::S3::Plugins::BucketNameRestrictions)
Expand Down Expand Up @@ -186,6 +188,16 @@ class Client < Seahorse::Client::Base
# * `~/.aws/credentials`
# * `~/.aws/config`
#
# @option options [Boolean] :access_grants (false)
# When `true`, the S3 client will use the S3 Access Grants feature to
# authenticate requests. Bucket credentials will be fetched from S3
# Control using the `get_data_access` API.
#
# @option options [Aws::S3::AccessGrantsCredentialsProvider] :access_grants_credentials_provider
# When `access_grants` is `true`, this option can be used to provide
# additional options to the credentials provider, including a privilege
# setting, caching, and fallback behavior.
#
# @option options [String] :access_key_id
#
# @option options [Boolean] :active_endpoint_cache (false)
Expand Down
5 changes: 5 additions & 0 deletions gems/aws-sdk-s3/lib/aws-sdk-s3/plugins/access_grants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,15 @@ def s3_express_endpoint?(context)
end

def add_handlers(handlers,config)
require 'aws-sdk-s3control'
handlers.add(Handler) if config.access_grants
rescue LoadError
false
end

def after_initialize(client)
return unless client.config.access_grants

provider = client.config.access_grants_credentials_provider
provider.s3_client = client unless provider.s3_client
end
Expand Down
2 changes: 2 additions & 0 deletions gems/aws-sdk-s3/sig/client.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module Aws
def self.new: (
?credentials: untyped,
?region: String,
?access_grants: bool,
?access_grants_credentials_provider: untyped,
?access_key_id: String,
?active_endpoint_cache: bool,
?adaptive_retry_wait_to_fill: bool,
Expand Down
2 changes: 2 additions & 0 deletions gems/aws-sdk-s3/sig/resource.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module Aws
?client: Client,
?credentials: untyped,
?region: String,
?access_grants: bool,
?access_grants_credentials_provider: untyped,
?access_key_id: String,
?active_endpoint_cache: bool,
?adaptive_retry_wait_to_fill: bool,
Expand Down
1 change: 0 additions & 1 deletion gems/aws-sdk-s3/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

$:.unshift(File.expand_path('../../lib', __FILE__))
$:.unshift(File.expand_path('../../../aws-sdk-kms/lib', __FILE__))
$:.unshift(File.expand_path('../../../aws-sdk-s3control/lib', __FILE__))
$:.unshift(File.expand_path('../../../aws-sigv4/lib', __FILE__))
$:.unshift(File.expand_path('../../../aws-sdk-core/lib', __FILE__))

Expand Down
1 change: 0 additions & 1 deletion services.json
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,6 @@
"models": "s3/2006-03-01",
"dependencies": {
"aws-sdk-kms": "~> 1",
"aws-sdk-s3control": "~> 1.73",
"aws-sigv4": "~> 1.8"
},
"addPlugins": [
Expand Down

0 comments on commit 5ca578f

Please sign in to comment.