Skip to content

Commit

Permalink
Move test for GovCloud or FIPS higher
Browse files Browse the repository at this point in the history
The code can be simplified if we move the test for GovCloud or FIPS
outside of the if use_virtual_hosted_style block.  This makes it
explicit what it's trying to do - which is disable the use of
acceleration.

We won't emit a warning here.  The corresponding code going into
the fog-aws gem will emit a warning once that code is merged. We
don't need two warnings for the same thing.
  • Loading branch information
matt-domsch-sp committed Nov 20, 2024
1 parent 3c8ad1f commit ae2a277
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/carrierwave/storage/fog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,14 @@ def public_url
regional_host = "s3.#{region}.amazonaws.com"
end

# GovCloud doesn't support S3 Transfer Acceleration https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-s3.html
# S3 Transfer Acceleration doesn't support FIPS endpoints. When both fog_aws_accelerate=true and AWS_USE_FIPS_ENDPOINT=true, don't use Accelerate.
if @uploader.fog_aws_accelerate && (AWS_GOVCLOUD_REGIONS.include?(region) || ENV['AWS_USE_FIPS_ENDPOINT'] == 'true')
@uploader.fog_aws_accelerate = false
end

if use_virtual_hosted_style
# GovCloud doesn't support S3 Transfer Acceleration https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-s3.html
# S3 Transfer Acceleration doesn't support FIPS endpoints. When both fog_aws_accelerate=true and AWS_USE_FIPS_ENDPOINT=true, don't use Accelerate.
regional_host = 's3-accelerate.amazonaws.com' if @uploader.fog_aws_accelerate && !AWS_GOVCLOUD_REGIONS.include?(region) && ENV['AWS_USE_FIPS_ENDPOINT'] != 'true'
regional_host = 's3-accelerate.amazonaws.com' if @uploader.fog_aws_accelerate
"#{protocol}://#{@uploader.fog_directory}.#{regional_host}/#{encoded_path}"
else # directory is not a valid subdomain, so use path style for access
"#{protocol}://#{regional_host}/#{@uploader.fog_directory}/#{encoded_path}"
Expand Down

0 comments on commit ae2a277

Please sign in to comment.