A module to enrich {Message} based on it originating from AutoScaling, which have a particular subject and message payload. Parses such messages into a more rich representation.
@return [Boolean] true when the SNS originates from auto-scaling
# File lib/aws/sns/originators/from_auto_scaling.rb, line 26 def applicable? sns sns['Subject'] =~ /.*autoscaling:.*/ end
# File lib/aws/sns/originators/from_auto_scaling.rb, line 21 def self.extended base base.origin = :autoscaling end
# File lib/aws/sns/originators/from_auto_scaling.rb, line 32 def body return @body if defined? @body @body = self.parse_from self.raw['Message'] end
@return [Symbol] the auto-scaling event name
# File lib/aws/sns/originators/from_auto_scaling.rb, line 38 def event return @event if defined? @event e = body['Event'] @event = case when e =~ /EC2_INSTANCE_TERMINATE/ then :ec2_instance_terminate when e =~ /EC2_INSTANCE_TERMINATE_ERROR/ then :ec2_instance_terminate_error when e =~ /EC2_INSTANCE_LAUNCH/ then :ec2_instance_launch when e =~ /EC2_INSTANCE_LAUNCH_ERROR/ then :ec2_instance_launch_error when e =~ /TEST_NOTIFICATION/ then :test_notification else :unknown end end
@return [String] the auto-scaling group name
# File lib/aws/sns/originators/from_auto_scaling.rb, line 52 def group_name body['AutoScalingGroupName'] end
@return [String] the instance-ID that is the subject of this event
# File lib/aws/sns/originators/from_auto_scaling.rb, line 61 def instance_id body['EC2InstanceId'] end
# File lib/aws/sns/originators/from_auto_scaling.rb, line 56 def status_code body['StatusCode'] end
@return [Boolean] true when the SNS originates from auto-scaling
# File lib/aws/sns/originators/from_auto_scaling.rb, line 26 def applicable? sns sns['Subject'] =~ /.*autoscaling:.*/ end