Module: Backends::Ec2::Helpers::ComputeDeleteHelper

Included in:
Compute
Defined in:
lib/backends/ec2/helpers/compute_delete_helper.rb

Instance Method Summary collapse

Instance Method Details

#delete_release_public(instance_ids) ⇒ Object

TODO: look for ways to DRY this up by re-using ComputeNetworkHelper


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/backends/ec2/helpers/compute_delete_helper.rb', line 7

def delete_release_public(instance_ids)
  filters = []
  filters << { name: 'instance-id', values: instance_ids }

  addresses = nil
  Backends::Ec2::Helpers::AwsConnectHelper.rescue_aws_service(@logger) do
    addresses = @ec2_client.describe_addresses(filters: filters).addresses
    addresses.each do |address|
      if address[:allocation_id] && address[:association_id]
        delete_release_public_vpc(address)
      else
        delete_release_public_nonvpc(address)
      end
    end
  end
end