module Cumulus::ELB::Loader

Public Class Methods

elbs() click to toggle source

Public: Load all the load balancer configurations as LoadBalancerConfig objects

Returns an array of LoadBalancerConfig

# File lib/elb/loader/Loader.rb, line 21
def self.elbs
  Common::BaseLoader::resources(@@elbs_dir, &LoadBalancerConfig.method(:new))
end
listener(name, vars) click to toggle source

Public: Load a specified listener template by name, applying any variables

name - the name of the listener template to load vars - the hash of vars to apply

returns

# File lib/elb/loader/Loader.rb, line 31
def self.listener(name, vars)
  Common::BaseLoader.template(
    name,
    @@listeners_dir,
    vars,
    &proc do |_, json|
      ListenerConfig.new(json)
    end
  )
end
policy(policy_name) click to toggle source

Public: Load the specified user defined policy as an AWS policy

Returns an Aws::ElasticLoadBalancing::Types::PolicyDescription

# File lib/elb/loader/Loader.rb, line 45
def self.policy(policy_name)
  Common::BaseLoader::resource(policy_name, @@policies_dir) do |policy_name, policy|
    Aws::ElasticLoadBalancing::Types::PolicyDescription.new({
      policy_name: policy_name,
      policy_type_name: policy.fetch("type"),
      policy_attribute_descriptions: policy.fetch("attributes").map do |key, value|
        Aws::ElasticLoadBalancing::Types::PolicyAttributeDescription.new({
          attribute_name: key,
          attribute_value: value
        })
      end
    })
  end
rescue KeyError
  puts "policy configuration #{policy_name} does not contain all required keys `type` and `attributes`"
  exit
end