class Aws::S3Control::Plugins::ARN
When an ARN
is provided for :bucket or :name in S3Control
operations, this plugin resolves the request endpoint from the ARN
when possible. @api private
Public Class Methods
resolve_arn!(member_value, region, use_arn_region)
click to toggle source
@api private
# File lib/aws-sdk-s3control/plugins/arn.rb, line 146 def resolve_arn!(member_value, region, use_arn_region) if Aws::ARNParser.arn?(member_value) arn = Aws::ARNParser.parse(member_value) if arn.resource.include?('bucket') s3_arn = Aws::S3Control::OutpostBucketARN.new(arn.to_h) elsif arn.resource.include?('accesspoint') s3_arn = Aws::S3Control::OutpostAccessPointARN.new(arn.to_h) else raise ArgumentError, 'Only Outpost Bucket and Outpost Access Point ARNs are '\ 'currently supported.' end s3_arn.validate_arn! validate_region_config!(s3_arn, region, use_arn_region) region = s3_arn.region if use_arn_region [region, s3_arn] else [region] end end
resolve_url!(url, arn, region, dualstack = false, has_custom_endpoint = false)
click to toggle source
@api private
# File lib/aws-sdk-s3control/plugins/arn.rb, line 168 def resolve_url!(url, arn, region, dualstack = false, has_custom_endpoint = false) custom_endpoint = url.host if has_custom_endpoint url.host = arn.host_url(region, dualstack, custom_endpoint) url end
Private Class Methods
resolve_s3_use_arn_region(cfg)
click to toggle source
# File lib/aws-sdk-s3control/plugins/arn.rb, line 176 def resolve_s3_use_arn_region(cfg) value = ENV['AWS_S3_USE_ARN_REGION'] || Aws.shared_config.s3_use_arn_region(profile: cfg.profile) || 'true' value = Aws::Util.str_2_bool(value) # Raise if provided value is not true or false if value.nil? raise ArgumentError, 'Must provide either `true` or `false` for the '\ '`s3_use_arn_region` profile option or for '\ "ENV['AWS_S3_USE_ARN_REGION']." end value end
validate_region_config!(arn, region, use_arn_region)
click to toggle source
# File lib/aws-sdk-s3control/plugins/arn.rb, line 191 def validate_region_config!(arn, region, use_arn_region) fips = arn.support_fips? # s3-external-1 is specific just to s3 and not part of partitions # aws-global is a partition region unless arn.partition == 'aws' && (region == 's3-external-1' || region == 'aws-global') if !fips && arn.region.include?('fips') raise ArgumentError, 'FIPS region ARNs are not supported for this type of ARN.' end if !fips && !use_arn_region && region.include?('fips') raise ArgumentError, 'FIPS client regions are not supported for this type of '\ 'ARN without `:s3_use_arn_region`.' end # if it's a fips region, attempt to normalize it if fips || use_arn_region region = region.gsub('fips-', '').gsub('-fips', '') end if use_arn_region && !Aws::Partitions.partition(arn.partition).region?(region) raise Aws::Errors::InvalidARNPartitionError end if !use_arn_region && region != arn.region raise Aws::Errors::InvalidARNRegionError end end end
Public Instance Methods
add_handlers(handlers, _config)
click to toggle source
param validator is validate:50 (required to add account_id from arn) endpoint is build:90 (populates the URI for the first time) endpoint pattern is build:10 (prefix account id to host)
# File lib/aws-sdk-s3control/plugins/arn.rb, line 29 def add_handlers(handlers, _config) handlers.add(ARNHandler, step: :validate, priority: 75) handlers.add(UrlHandler) end