Created
May 3, 2014 15:03
-
-
Save trlinkin/e452440f9fbc72a7a6af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'yaml' | |
require 'aws-sdk' | |
config_file = File.join(File.dirname(__FILE__),"config.yml") | |
config = YAML.load(File.read(config_file)) | |
AWS.config(config) | |
sqs = AWS::SQS.new | |
queue = sqs.queues[config['queue_url']] | |
queue.poll do |msg| | |
sns = msg.as_sns_message.body_message_as_h | |
if sns['Event'] == 'autoscaling:EC2_INSTANCE_TERMINATE' | |
%x"puppet cert clean #{sns['EC2InstanceId']}.aws" | |
%x"puppet node deactivate #{sns['EC2InstanceId']}.aws" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment