That error message means that on line 20 of policies.rb
there is code like foo.reduce
and foo
happens to be nil
.
If we look at the source code of the gem, we see:
def munged_data
data.reduce([]){ |m,e| # line 20
So, the problem is that data
is nil
when the munged_data
method is called. We see on line 8 of the same file that data
is defined via a simple attr_accessor
call. I cannot tell for sure where that should have been set. (There are 227 instances of @data =
or data =
in the gem.) This seems like a bug in the AWS gem, unless you were supposed to call some method before calling .all
on policies
.
Tracing further, we see that policies
is defined in load_balancer.rb
on line 154 as:
def policies
Fog::AWS::ELB::Policies.new({
:data => policy_descriptions,
:service => service,
:load_balancer => self
})
end
Assuming that the data
passed to the method is used directly as the @data
instance variable, then the problem is that policy_descriptions
returned nil
.
The implementation of policy_descriptions
is:
def policy_descriptions
requires :id
@policy_descriptions ||= service.describe_load_balancer_policies(id).body["DescribeLoadBalancerPoliciesResult"]["PolicyDescriptions"]
end
If service.describe_load_balancer_policies(id).body["DescribeLoadBalancerPoliciesResult"]
returned nil
(or any object that did not have a []
method) this method would have thrown an error. So, my deduction is that this returned something like a hash, but that hash has no "PolicyDescriptions"
key.
From there...I don't know.