bin/handler-ec2_node.rb in sensu-plugins-aws-2.3.0 vs bin/handler-ec2_node.rb in sensu-plugins-aws-2.4.0
- old
+ new
@@ -167,10 +167,10 @@
else
# Checking for instance state and reason, and if matches any of the user defined or default reasons then
# method returns True
# Returns instance state reason in AWS i.e: "Client.UserInitiatedShutdown"
- instance_state_reason = instances.instances[0].state_reason.code
+ instance_state_reason = instances.instances[0].state_reason.nil? ? nil : instances.instances[0].state_reason.code
# Returns the instance state i.e: "terminated"
instance_state = instances.instances[0].state.name
# Return true is instance state and instance reason is valid
instance_states.include?(instance_state) && instance_reasons.include?(instance_state_reason)