Skip to content

Commit f77eb28

Browse files
authored
Raise when accelerate and fips are provided in s3 (#2610)
1 parent f211d8c commit f77eb28

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

gems/aws-sdk-s3/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Issue - Raise error when `use_fips_endpoint` is used with `use_accelerate_endpoint`.
5+
46
1.105.0 (2021-11-04)
57
------------------
68

gems/aws-sdk-s3/lib/aws-sdk-s3/plugins/accelerate.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ def call(context)
4646
raise ArgumentError,
4747
'Cannot use both :use_accelerate_endpoint and :endpoint'
4848
end
49+
# Raise if :use_fips_endpoint and accelerate are both provided
50+
if accelerate && context.config.use_fips_endpoint
51+
raise ArgumentError,
52+
'Cannot use both :use_accelerate_endpoint and '\
53+
':use_fips_endpoint'
54+
end
4955
context[:use_accelerate_endpoint] = accelerate
5056
@handler.call(context)
5157
end

gems/aws-sdk-s3/spec/client/accelerate_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,26 @@ module S3
6565
)
6666
end
6767

68+
it 'raises when accelerate and endpoint are configured' do
69+
expect do
70+
Client.new(
71+
options.merge(
72+
use_accelerate_endpoint: true, endpoint: 'https://amazon.com'
73+
)
74+
).put_object(bucket: 'bucket-name', key: 'key')
75+
end.to raise_error(ArgumentError, /:endpoint/)
76+
end
77+
78+
it 'raises when accelerate and use_fips_endpoint are configured' do
79+
expect do
80+
Client.new(
81+
options.merge(
82+
use_accelerate_endpoint: true, use_fips_endpoint: true
83+
)
84+
).put_object(bucket: 'bucket-name', key: 'key')
85+
end.to raise_error(ArgumentError, /:use_fips_endpoint/)
86+
end
87+
6888
it 'does not apply to #create_bucket' do
6989
resp = accelerated_client.create_bucket(bucket: 'bucket-name')
7090
expect(resp.context.http_request.endpoint.to_s).to eq(

0 commit comments

Comments
 (0)