Class: Mapper
- Inherits:
-
Object
- Object
- Mapper
- Defined in:
- lib/aws_recon/lib/mapper.rb
Overview
Generic wrapper for service clients.
Paging
The AWS Ruby SDK has a built-in enumerator in the client response object that automatically handles paging large requests. Confirm the AWS SDK client call returns a Aws::PageableResponse to take advantage of automatic paging.
Retries
The AWS Ruby SDK performs retries automatically. We change the retry_limit to 9 (10 total requests) and the retry_backoff to add 5 seconds delay on each retry for a total max of 55 seconds.
Direct Known Subclasses
ACM, APIGateway, AccessAnalyzer, ApiGatewayV2, ApplicationAutoScaling, Athena, AutoScaling, Backup, CloudFormation, CloudFront, CloudTrail, CloudWatch, CloudWatchLogs, CodeBuild, CodePipeline, ConfigService, DatabaseMigrationService, DirectConnect, DirectoryService, DynamoDB, EC2, ECR, ECRPublic, ECS, EFS, EKS, EMR, ElastiCache, ElasticLoadBalancing, ElasticLoadBalancingV2, ElasticsearchService, Firehose, Glue, GuardDuty, IAM, KMS, Kafka, Kinesis, Lambda, Lightsail, Organizations, RDS, Redshift, Route53, Route53Domains, S3, SES, SNS, SQS, SSM, SageMaker, SecretsManager, SecurityHub, ServiceQuotas, Shield, Support, Transfer, WAFV2, WorkSpaces, XRay
Constant Summary collapse
- SINGLE_REGION_SERVICES =
Services that use us-east-1 endpoint only:
Organizations Route53Domains Shield S3 (unless the bucket was created in another region)
%w[route53domains s3 shield support organizations].freeze
Instance Method Summary collapse
-
#initialize(account, service, region, options) ⇒ Mapper
constructor
A new instance of Mapper.
Constructor Details
#initialize(account, service, region, options) ⇒ Mapper
Returns a new instance of Mapper.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/aws_recon/lib/mapper.rb', line 27 def initialize(account, service, region, ) @account = account @service = service @region = region @options = @thread = Parallel.worker_number || 0 # build the client interface module_name = "Aws::#{service}::Client" # incremental delay on retries (seconds) retry_delay = 5 # default is 3 retries, with 15 second sleep in between # reset to 9 retries, with incremental backoff = { retry_mode: 'legacy', # legacy, standard, or adaptive retry_limit: 9, # only legacy retry_backoff: ->(context) { sleep(retry_delay * context.retries + 1) }, # only legacy http_read_timeout: 10 } # regional service .merge!({ region: region }) unless region == 'global' # single region services .merge!({ region: 'us-east-1' }) if SINGLE_REGION_SERVICES.include?(service.downcase) # rubocop:disable Layout/LineLength # debug with wire trace .merge!({ http_wire_trace: true }) if @options.debug @client = Object.const_get(module_name).new() end |