Class: Awsrm::Alb
Constant Summary
collapse
- FILTER_MAP =
{
id: 'load_balancer_name',
arn: 'load_balancer_arn',
name: 'load_balancer_name',
dns_name: 'dns_name',
tags: ->(lb, value) { Alb.has_tags?(lb.load_balancer_arn, value) },
vpc: ->(lb, value) { lb.vpc_id == Awsrm::Vpc.one(name: value).id }
}.freeze
Constants inherited
from Resource
Resource::CLIENTS, Resource::CLIENT_OPTIONS
Class Method Summary
collapse
Methods inherited from Resource
check_one, one
Class Method Details
.all(params) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/awsrm/resources/alb.rb', line 13
def all(params)
lbs = elbv2_client.describe_load_balancers.map do |responce|
responce.load_balancers
end.flatten
albs = lbs.select do |lb|
lb.type == 'application'
end
albs.map do |lb|
ret = params.all? do |key, value|
raise UndefinedFilterParamError, key unless self::FILTER_MAP.key?(key)
next self::FILTER_MAP[key].call(lb, value) if self::FILTER_MAP[key].is_a?(Proc)
lb[self::FILTER_MAP[key]] == value
end
AlbReader.new(lb) if ret
end.compact
end
|
.filters(_params) ⇒ Object
30
31
32
|
# File 'lib/awsrm/resources/alb.rb', line 30
def filters(_params)
raise NoMethodError
end
|
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/awsrm/resources/alb.rb', line 34
def has_tags?(arn, tag_hash)
tag_descriptions = elbv2_client.describe_tags(resource_arns: [arn]).tag_descriptions.flatten
ret = tag_descriptions.find do |desc|
desc.resource_arn == arn
end
return false if ret.nil?
tag_hash.all? do |key, value|
ret.tags.any? do |tag|
tag.key == key.to_s && tag.value == value.to_s
end
end
end
|