Module: Ufo::AwsServices

Defined Under Namespace

Modules: Concerns

Instance Method Summary collapse

Methods included from Concerns

#find_stack, #find_stack_resources, #stack_resources, #status, #task_definition_arns

Instance Method Details

#acmObject



20
21
22
# File 'lib/ufo/aws_services.rb', line 20

def acm
  Aws::ACM::Client.new(aws_options)
end

#applicationautoscalingObject



25
26
27
# File 'lib/ufo/aws_services.rb', line 25

def applicationautoscaling
  Aws::ApplicationAutoScaling::Client.new(aws_options)
end

#aws_optionsObject

Override the AWS retry settings with AWS clients.

The aws-sdk-core has exponential backup with this formula:

2 ** c.retries * c.config.retry_base_delay

Source:

https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-core/lib/aws-sdk-core/plugins/retry_errors.rb

So the max delay will be 2 ** 7 * 0.6 = 76.8s

Only scoping this to deploy because dont want to affect people’s application that use the aws sdk.

There is also additional rate backoff logic elsewhere, since this is only scoped to deploys.

Useful links:

https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-core/lib/aws-sdk-core/plugins/retry_errors.rb
https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html


96
97
98
99
100
101
102
103
104
105
106
# File 'lib/ufo/aws_services.rb', line 96

def aws_options
  options = {
    retry_limit: 7, # default: 3
    retry_base_delay: 0.6, # default: 0.3
  }
  options.merge!(
    log_level: :debug,
    logger: Logger.new($stdout),
  ) if ENV['UFO_DEBUG_AWS_SDK']
  options
end

#cfnObject



30
31
32
# File 'lib/ufo/aws_services.rb', line 30

def cfn
  Aws::CloudFormation::Client.new(aws_options)
end

#cloudwatchlogsObject



35
36
37
# File 'lib/ufo/aws_services.rb', line 35

def cloudwatchlogs
  Aws::CloudWatchLogs::Client.new(aws_options)
end

#ec2Object



40
41
42
# File 'lib/ufo/aws_services.rb', line 40

def ec2
  Aws::EC2::Client.new(aws_options)
end

#ecrObject



45
46
47
# File 'lib/ufo/aws_services.rb', line 45

def ecr
  Aws::ECR::Client.new(aws_options)
end

#ecsObject



50
51
52
# File 'lib/ufo/aws_services.rb', line 50

def ecs
  Aws::ECS::Client.new(aws_options)
end

#elbObject



55
56
57
# File 'lib/ufo/aws_services.rb', line 55

def elb
  Aws::ElasticLoadBalancingV2::Client.new(aws_options)
end

#s3Object



60
61
62
# File 'lib/ufo/aws_services.rb', line 60

def s3
  Aws::S3::Client.new(aws_options)
end

#ssm_clientObject

ssm is a helper method



66
67
68
# File 'lib/ufo/aws_services.rb', line 66

def ssm_client
  Aws::SSM::Client.new(aws_options)
end

#waf_clientObject

waf is a helper method



72
73
74
# File 'lib/ufo/aws_services.rb', line 72

def waf_client
  Aws::WAFV2::Client.new(aws_options)
end