You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
Module: AWS::SNS::FromAutoScaling
- Defined in:
- lib/aws/sns/originators/from_auto_scaling.rb
Overview
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.
Class Method Summary collapse
-
.applicable?(sns) ⇒ Boolean
True when the SNS originates from auto-scaling.
-
.extended(base) ⇒ Object
Instance Method Summary collapse
-
#body ⇒ Object
-
#event ⇒ Symbol
The auto-scaling event name.
-
#group_name ⇒ String
The auto-scaling group name.
-
#instance_id ⇒ String
The instance-ID that is the subject of this event.
-
#status_code ⇒ Object
Class Method Details
.applicable?(sns) ⇒ Boolean
Returns true when the SNS originates from auto-scaling
26 27 28 |
# File 'lib/aws/sns/originators/from_auto_scaling.rb', line 26 def applicable? sns sns['Subject'] =~ /.*autoscaling:.*/i end |
.extended(base) ⇒ Object
21 22 23 |
# File 'lib/aws/sns/originators/from_auto_scaling.rb', line 21 def self.extended base base.origin = :autoscaling end |
Instance Method Details
#body ⇒ Object
32 33 34 35 |
# 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 ⇒ Symbol
Returns the auto-scaling event name
38 39 40 41 42 43 44 45 46 47 48 49 |
# 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 ⇒ String
Returns the auto-scaling group name
52 53 54 |
# File 'lib/aws/sns/originators/from_auto_scaling.rb', line 52 def group_name body['AutoScalingGroupName'] end |
#instance_id ⇒ String
Returns the instance-ID that is the subject of this event
61 62 63 |
# File 'lib/aws/sns/originators/from_auto_scaling.rb', line 61 def instance_id body['EC2InstanceId'] end |
#status_code ⇒ Object
56 57 58 |
# File 'lib/aws/sns/originators/from_auto_scaling.rb', line 56 def status_code body['StatusCode'] end |