Class: AwsCleaner
- Inherits:
-
Object
- Object
- AwsCleaner
- Defined in:
- lib/aws-cleaner.rb
Overview
main aws_cleaner lib
Defined Under Namespace
Modules: Chef, Notify, SQS, Sensu, Webhooks
Instance Method Summary collapse
-
#delete_message(id, config) ⇒ Object
delete the message from SQS.
-
#parse(body) ⇒ Object
return the body of the SQS message in JSON.
-
#process_message(message_body) ⇒ Object
return the instance_id of the terminated instance.
Instance Method Details
#delete_message(id, config) ⇒ Object
delete the message from SQS
14 15 16 17 18 19 20 |
# File 'lib/aws-cleaner.rb', line 14 def (id, config) delete = AwsCleaner::SQS.client(config).( queue_url: config[:sqs][:queue], receipt_handle: id ) delete ? true : false end |
#parse(body) ⇒ Object
return the body of the SQS message in JSON
102 103 104 105 106 |
# File 'lib/aws-cleaner.rb', line 102 def parse(body) JSON.parse(body) rescue JSON::ParserError return false end |
#process_message(message_body) ⇒ Object
return the instance_id of the terminated instance
109 110 111 112 113 114 115 |
# File 'lib/aws-cleaner.rb', line 109 def () return false if ['detail']['instance-id'].nil? && ['detail']['state'] != 'terminated' instance_id = ['detail']['instance-id'] instance_id end |