Skip to content

Instantly share code, notes, and snippets.

@pcarrier
Created April 3, 2013 03:00
Show Gist options
  • Select an option

  • Save pcarrier/5298109 to your computer and use it in GitHub Desktop.

Select an option

Save pcarrier/5298109 to your computer and use it in GitHub Desktop.
destroy_instance.rb:
#!/usr/bin/env ruby
EventBusWorker.new do |e|
msg = e.publish 'destroy_instance', {:id => ARGV[1]}
e.wait_for 'aws_destroyed', {:req => msg}
e.wait_for 'scout_removed', {:req => msg}
end
aws_destroyed.rb:
EventBusWorker.new do |e|
sub = e.subscribe('destroy_instance')
sub.received do |msg|
e.publish 'aws_destroying', {:id => msg.id, :req => msg}
AWS::EC2.new.destroy :id
e.publish 'aws_destroyed', {:id => msg.id, :req => msg}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment