module AWS::SNS::FromAutoScaling

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.

Public Class Methods

applicable?(sns) click to toggle source

@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
extended(base) click to toggle source
# File lib/aws/sns/originators/from_auto_scaling.rb, line 21
def self.extended base
  base.origin = :autoscaling
end

Public Instance Methods

body() click to toggle source
# 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
event() click to toggle source

@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
group_name() click to toggle source

@return [String] the auto-scaling group name

# File lib/aws/sns/originators/from_auto_scaling.rb, line 52
def group_name
  body['AutoScalingGroupName']
end
instance_id() click to toggle source

@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
status_code() click to toggle source
# File lib/aws/sns/originators/from_auto_scaling.rb, line 56
def status_code
  body['StatusCode']
end

Private Instance Methods

applicable?(sns) click to toggle source

@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