Module: Cumulus::ELB::Loader
- Includes:
- Common::BaseLoader
- Defined in:
- lib/elb/loader/Loader.rb
Constant Summary collapse
- @@elbs_dir =
Configuration.instance.elb.load_balancers_directory
- @@listeners_dir =
Configuration.instance.elb.listeners_directory
- @@policies_dir =
Configuration.instance.elb.policies_directory
Class Method Summary collapse
-
.elbs ⇒ Object
Public: Load all the load balancer configurations as LoadBalancerConfig objects.
-
.listener(name, vars) ⇒ Object
Public: Load a specified listener template by name, applying any variables.
-
.policy(policy_name) ⇒ Object
Public: Load the specified user defined policy as an AWS policy.
Methods included from Common::BaseLoader
load_file, resource, resources, template
Class Method Details
.elbs ⇒ Object
Public: Load all the load balancer configurations as LoadBalancerConfig objects
Returns an array of LoadBalancerConfig
21 22 23 |
# File 'lib/elb/loader/Loader.rb', line 21 def self.elbs Common::BaseLoader::resources(@@elbs_dir, &LoadBalancerConfig.method(:new)) end |
.listener(name, vars) ⇒ Object
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
31 32 33 34 35 36 37 38 39 40 |
# 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) ⇒ Object
Public: Load the specified user defined policy as an AWS policy
Returns an Aws::ElasticLoadBalancing::Types::PolicyDescription
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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 |