Class: Bosh::AwsCliPlugin::RdsDestroyer

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh_cli_plugin_aws/rds_destroyer.rb

Instance Method Summary collapse

Constructor Details

#initialize(ui, config) ⇒ RdsDestroyer

Returns a new instance of RdsDestroyer.


3
4
5
6
# File 'lib/bosh_cli_plugin_aws/rds_destroyer.rb', line 3

def initialize(ui, config)
  @ui = ui
  @credentials = config['aws']
end

Instance Method Details

#delete_allObject


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bosh_cli_plugin_aws/rds_destroyer.rb', line 8

def delete_all
  formatted_names = rds.database_names.map { |instance, db| "#{instance}\t(database_name: #{db})" }

  @ui.say("THIS IS A VERY DESTRUCTIVE OPERATION AND IT CANNOT BE UNDONE!\n".make_red)
  @ui.say("Database Instances:\n\t#{formatted_names.join("\n\t")}")

  if @ui.confirmed?('Are you sure you want to delete all databases?')
    rds.delete_databases unless formatted_names.empty?

    unless all_rds_instances_deleted?
      raise 'not all rds instances could be deleted'
    end

    rds.delete_subnet_groups
    rds.delete_security_groups
    rds.delete_db_parameter_group('utf8')
  end
end