Class: AwsClients

Inherits:
Object
  • Object
show all
Defined in:
lib/geoengineer/utils/aws_clients.rb

Overview

AwsClients contains a list of aws-clients for use The main reason for their central management is their initialisation testing and stubbing

Class Method Summary collapse

Class Method Details

.alb(provider = nil) ⇒ Object

Clients



29
30
31
32
33
34
# File 'lib/geoengineer/utils/aws_clients.rb', line 29

def self.alb(provider = nil)
  self.client_cache(
    provider,
    Aws::ElasticLoadBalancingV2::Client
  )
end

.api_gateway(provider = nil) ⇒ Object



36
37
38
39
40
41
# File 'lib/geoengineer/utils/aws_clients.rb', line 36

def self.api_gateway(provider = nil)
  self.client_cache(
    provider,
    Aws::APIGateway::Client
  )
end

.client_cache(provider, client) ⇒ Object



21
22
23
24
25
# File 'lib/geoengineer/utils/aws_clients.rb', line 21

def self.client_cache(provider, client)
  @client_cache ||= {}
  key = "#{client.name}_" + (provider&.terraform_id || GeoEngineer::Resource::DEFAULT_PROVIDER)
  @client_cache[key] ||= client.new(client_params(provider))
end

.client_params(provider = nil) ⇒ Object



14
15
16
17
18
19
# File 'lib/geoengineer/utils/aws_clients.rb', line 14

def self.client_params(provider = nil)
  client_params = { stub_responses: stubbed? }
  client_params[:region] = provider.region if provider
  client_params[:retry_limit] = Integer(ENV['AWS_RETRY_LIMIT']) if ENV['AWS_RETRY_LIMIT']
  client_params
end

.cloudfront(provider = nil) ⇒ Object



43
44
45
46
47
48
# File 'lib/geoengineer/utils/aws_clients.rb', line 43

def self.cloudfront(provider = nil)
  self.client_cache(
    provider,
    Aws::CloudFront::Client
  )
end

.cloudtrail(provider = nil) ⇒ Object



169
170
171
172
173
174
# File 'lib/geoengineer/utils/aws_clients.rb', line 169

def self.cloudtrail(provider = nil)
  self.client_cache(
    provider,
    Aws::CloudTrail::Client
  )
end

.cloudwatch(provider = nil) ⇒ Object



50
51
52
53
54
55
# File 'lib/geoengineer/utils/aws_clients.rb', line 50

def self.cloudwatch(provider = nil)
  self.client_cache(
    provider,
    Aws::CloudWatch::Client
  )
end

.cloudwatchevents(provider = nil) ⇒ Object



57
58
59
60
61
62
# File 'lib/geoengineer/utils/aws_clients.rb', line 57

def self.cloudwatchevents(provider = nil)
  self.client_cache(
    provider,
    Aws::CloudWatchEvents::Client
  )
end

.dynamo(provider = nil) ⇒ Object



64
65
66
67
68
69
# File 'lib/geoengineer/utils/aws_clients.rb', line 64

def self.dynamo(provider = nil)
  self.client_cache(
    provider,
    Aws::DynamoDB::Client
  )
end

.ec2(provider = nil) ⇒ Object



71
72
73
74
75
76
# File 'lib/geoengineer/utils/aws_clients.rb', line 71

def self.ec2(provider = nil)
  self.client_cache(
    provider,
    Aws::EC2::Client
  )
end

.efs(provider = nil) ⇒ Object



197
198
199
200
201
202
# File 'lib/geoengineer/utils/aws_clients.rb', line 197

def self.efs(provider = nil)
  self.client_cache(
    provider,
    Aws::EFS::Client
  )
end

.elasticache(provider = nil) ⇒ Object



78
79
80
81
82
83
# File 'lib/geoengineer/utils/aws_clients.rb', line 78

def self.elasticache(provider = nil)
  self.client_cache(
    provider,
    Aws::ElastiCache::Client
  )
end

.elasticsearch(provider = nil) ⇒ Object



85
86
87
88
89
90
# File 'lib/geoengineer/utils/aws_clients.rb', line 85

def self.elasticsearch(provider = nil)
  self.client_cache(
    provider,
    Aws::ElasticsearchService::Client
  )
end

.elb(provider = nil) ⇒ Object



92
93
94
95
96
97
# File 'lib/geoengineer/utils/aws_clients.rb', line 92

def self.elb(provider = nil)
  self.client_cache(
    provider,
    Aws::ElasticLoadBalancing::Client
  )
end

.emr(provider = nil) ⇒ Object



190
191
192
193
194
195
# File 'lib/geoengineer/utils/aws_clients.rb', line 190

def self.emr(provider = nil)
  self.client_cache(
    provider,
    Aws::EMR::Client
  )
end

.iam(provider = nil) ⇒ Object



99
100
101
102
103
104
# File 'lib/geoengineer/utils/aws_clients.rb', line 99

def self.iam(provider = nil)
  self.client_cache(
    provider,
    Aws::IAM::Client
  )
end

.kinesis(provider = nil) ⇒ Object



106
107
108
109
110
111
# File 'lib/geoengineer/utils/aws_clients.rb', line 106

def self.kinesis(provider = nil)
  self.client_cache(
    provider,
    Aws::Kinesis::Client
  )
end

.kms(provider = nil) ⇒ Object



176
177
178
179
180
181
# File 'lib/geoengineer/utils/aws_clients.rb', line 176

def self.kms(provider = nil)
  self.client_cache(
    provider,
    Aws::KMS::Client
  )
end

.lambda(provider = nil) ⇒ Object



113
114
115
116
117
118
# File 'lib/geoengineer/utils/aws_clients.rb', line 113

def self.lambda(provider = nil)
  self.client_cache(
    provider,
    Aws::Lambda::Client
  )
end

.rds(provider = nil) ⇒ Object



120
121
122
123
124
125
# File 'lib/geoengineer/utils/aws_clients.rb', line 120

def self.rds(provider = nil)
  self.client_cache(
    provider,
    Aws::RDS::Client
  )
end

.redshift(provider = nil) ⇒ Object



127
128
129
130
131
132
# File 'lib/geoengineer/utils/aws_clients.rb', line 127

def self.redshift(provider = nil)
  self.client_cache(
    provider,
    Aws::Redshift::Client
  )
end

.route53(provider = nil) ⇒ Object



134
135
136
137
138
139
# File 'lib/geoengineer/utils/aws_clients.rb', line 134

def self.route53(provider = nil)
  self.client_cache(
    provider,
    Aws::Route53::Client
  )
end

.s3(provider = nil) ⇒ Object



141
142
143
144
145
146
# File 'lib/geoengineer/utils/aws_clients.rb', line 141

def self.s3(provider = nil)
  self.client_cache(
    provider,
    Aws::S3::Client
  )
end

.ses(provider = nil) ⇒ Object



148
149
150
151
152
153
# File 'lib/geoengineer/utils/aws_clients.rb', line 148

def self.ses(provider = nil)
  self.client_cache(
    provider,
    Aws::SES::Client
  )
end

.sns(provider = nil) ⇒ Object



155
156
157
158
159
160
# File 'lib/geoengineer/utils/aws_clients.rb', line 155

def self.sns(provider = nil)
  self.client_cache(
    provider,
    Aws::SNS::Client
  )
end

.sqs(provider = nil) ⇒ Object



162
163
164
165
166
167
# File 'lib/geoengineer/utils/aws_clients.rb', line 162

def self.sqs(provider = nil)
  self.client_cache(
    provider,
    Aws::SQS::Client
  )
end

.stub!Object



6
7
8
# File 'lib/geoengineer/utils/aws_clients.rb', line 6

def self.stub!
  @stub_aws = true
end

.stubbed?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/geoengineer/utils/aws_clients.rb', line 10

def self.stubbed?
  @stub_aws || false
end

.waf(provider = nil) ⇒ Object



183
184
185
186
187
188
# File 'lib/geoengineer/utils/aws_clients.rb', line 183

def self.waf(provider = nil)
  self.client_cache(
    provider,
    Aws::WAF::Client
  )
end