bin/handler-ec2_node.rb in sensu-plugins-aws-1.2.0 vs bin/handler-ec2_node.rb in sensu-plugins-aws-2.0.0
- old
+ new
@@ -134,10 +134,10 @@
instances = ec2.describe_instances(instance_ids: [@event['client']['name']]).reservations[0]
if instances.nil? || instances.empty?
true
else
instance = instances.instances[0]
- state_reason = instance.state_reason.code
+ state_reason = instance.state_reason.nil? ? nil : instance.state_reason.code
state = instance.state.name
states.include?(state) && state_reasons.any? { |reason| Regexp.new(reason) =~ state_reason }
end
rescue Aws::EC2::Errors::InvalidInstanceIDNotFound
true