Class: AwsElbs

Inherits:
Object
  • Object
show all
Includes:
AwsPluralResourceMixin
Defined in:
lib/resources/aws/aws_elbs.rb

Defined Under Namespace

Classes: Backend

Instance Attribute Summary

Attributes included from AwsPluralResourceMixin

#table

Instance Method Summary collapse

Methods included from AwsPluralResourceMixin

included

Methods included from AwsResourceMixin

#catch_aws_errors, #check_resource_param_names, #initialize, #inspec_runner

Instance Method Details

#fetch_from_apiObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/resources/aws/aws_elbs.rb', line 40

def fetch_from_api
  backend = BackendFactory.create(inspec_runner)
  @table = []
  pagination_opts = {}
  loop do
    api_result = backend.describe_load_balancers(pagination_opts)
    @table += unpack_describe_elbs_response(api_result.load_balancer_descriptions)
    break unless api_result.next_marker
    pagination_opts = { marker: api_result.next_marker }
  end
end

#to_sObject



36
37
38
# File 'lib/resources/aws/aws_elbs.rb', line 36

def to_s
  'AWS ELBs'
end

#unpack_describe_elbs_response(load_balancers) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/resources/aws/aws_elbs.rb', line 52

def unpack_describe_elbs_response(load_balancers)
  load_balancers.map do |lb_struct|
    {
      availability_zones: lb_struct.availability_zones,
      dns_name: lb_struct.dns_name,
      external_ports: lb_struct.listener_descriptions.map { |ld| ld.listener.load_balancer_port },
      instance_ids: lb_struct.instances.map(&:instance_id),
      internal_ports: lb_struct.listener_descriptions.map { |ld| ld.listener.instance_port },
      elb_name: lb_struct.load_balancer_name,
      security_group_ids: lb_struct.security_groups,
      subnet_ids: lb_struct.subnets,
      vpc_id: lb_struct.vpc_id,
    }
  end
end

#validate_params(resource_params) ⇒ Object



12
13
14
15
16
17
# File 'lib/resources/aws/aws_elbs.rb', line 12

def validate_params(resource_params)
  unless resource_params.empty?
    raise ArgumentError, 'aws_elbs does not accept resource parameters.'
  end
  resource_params
end