class Aws::S3::Plugins::ARN::ARNHandler

This plugin will extract out any ARN input and set context for other plugins to use without having to translate the ARN again.

Public Instance Methods

call(context) click to toggle source
# File lib/aws-sdk-s3/plugins/arn.rb, line 69
def call(context)
  bucket_member = _bucket_member(context.operation.input.shape)
  if bucket_member && (bucket = context.params[bucket_member])
    resolved_region, arn = ARN.resolve_arn!(
      bucket,
      context.config.region,
      context.config.s3_use_arn_region
    )
    if arn
      validate_config!(context, arn)

      fips = false
      if resolved_region.include?('fips')
        fips = true
        resolved_region = resolved_region.gsub('fips-', '')
                                         .gsub('-fips', '')
      end

      context.metadata[:s3_arn] = {
        arn: arn,
        resolved_region: resolved_region,
        fips: fips,
        dualstack: extract_dualstack_config!(context)
      }
    end
  end
  @handler.call(context)
end

Private Instance Methods

_bucket_member(input) click to toggle source
# File lib/aws-sdk-s3/plugins/arn.rb, line 100
def _bucket_member(input)
  input.members.each do |member, ref|
    return member if ref.shape.name == 'BucketName'
  end
  nil
end
extract_dualstack_config!(context) click to toggle source

other plugins use dualstack so disable it when we're done

# File lib/aws-sdk-s3/plugins/arn.rb, line 108
def extract_dualstack_config!(context)
  dualstack = context[:use_dualstack_endpoint]
  context[:use_dualstack_endpoint] = false if dualstack
  dualstack
end
validate_config!(context, arn) click to toggle source
# File lib/aws-sdk-s3/plugins/arn.rb, line 114
def validate_config!(context, arn)
  if context.config.force_path_style
    raise ArgumentError,
          'Cannot provide an Access Point ARN when '\
          '`:force_path_style` is set to true.'
  end

  if context.config.use_accelerate_endpoint
    raise ArgumentError,
          'Cannot provide an Access Point ARN when '\
          '`:use_accelerate_endpoint` is set to true.'
  end

  if !arn.support_dualstack? && context[:use_dualstack_endpoint]
    raise ArgumentError,
          'Cannot provide an Outpost Access Point or Multi-region Access Point ARN'\
          ' when `:use_dualstack_endpoint` is set to true.'
  end

  if arn.region.empty? && context.config.s3_disable_multiregion_access_points
    raise ArgumentError,
          'Cannot provide a Multi-region Access Point ARN with '\
          '`:s3_disable_multiregion_access_points` set to true'
  end
end