Sha256: 38931bf5030fe2a6800c706dd82c24b368b1a8c7343f48036868fe70e0200b5a
Contents?: true
Size: 679 Bytes
Versions: 7
Compression:
Stored size: 679 Bytes
Contents
module Forger class Destroy < Base include AwsService def run(instance_id) puts "Destroying #{instance_id}" return if ENV['TEST'] cancel_spot_request(instance_id) ec2.terminate_instances(instance_ids: [instance_id]) puts "Instance #{instance_id} terminated." end def cancel_spot_request(instance_id) resp = ec2.describe_instances(instance_ids: [instance_id]) spot_id = resp.reservations.first.instances.first.spot_instance_request_id return unless spot_id ec2.cancel_spot_instance_requests(spot_instance_request_ids: [spot_id]) puts "Spot instance request #{spot_id} cancelled." end end end
Version data entries
7 entries across 7 versions & 1 rubygems