bosh_cli_plugin_aws 1.5.0.pre.1193 → 1.5.0.pre.1209
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bosh/cli/commands/aws.rb +95 -109
- data/lib/bosh_cli_plugin_aws/destroyer.rb +21 -0
- data/lib/bosh_cli_plugin_aws/version.rb +1 -1
- metadata +12 -11
@@ -1,10 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require_relative
|
1
|
+
require 'aws-sdk'
|
2
|
+
require 'securerandom'
|
3
|
+
require_relative '../../../bosh_cli_plugin_aws'
|
4
|
+
require 'bosh_cli_plugin_aws/destroyer'
|
4
5
|
|
5
6
|
module Bosh::Cli::Command
|
6
7
|
class AWS < Base
|
7
|
-
DEFAULT_CIDR =
|
8
|
+
DEFAULT_CIDR = '10.0.0.0/16' # KILL
|
8
9
|
|
9
10
|
attr_reader :output_state, :config_dir, :ec2
|
10
11
|
attr_accessor :vpc
|
@@ -14,16 +15,16 @@ module Bosh::Cli::Command
|
|
14
15
|
@output_state = {}
|
15
16
|
end
|
16
17
|
|
17
|
-
usage
|
18
|
-
desc
|
18
|
+
usage 'aws'
|
19
|
+
desc 'show bosh aws sub-commands'
|
19
20
|
def help
|
20
21
|
say "bosh aws sub-commands:\n"
|
21
22
|
commands = Bosh::Cli::Config.commands.values.find_all { |command| command.usage =~ /^aws/ }
|
22
23
|
Bosh::Cli::Command::Help.list_commands(commands)
|
23
24
|
end
|
24
25
|
|
25
|
-
usage
|
26
|
-
desc
|
26
|
+
usage 'aws bootstrap micro'
|
27
|
+
desc 'rm deployments dir, creates a deployments/micro/micro_bosh.yml and deploys the microbosh'
|
27
28
|
def bootstrap_micro
|
28
29
|
options[:hm_director_password] = SecureRandom.base64
|
29
30
|
options[:hm_director_user] ||= 'hm'
|
@@ -34,21 +35,21 @@ module Bosh::Cli::Command
|
|
34
35
|
bootstrap.create_user(options[:hm_director_user], options[:hm_director_password])
|
35
36
|
|
36
37
|
if interactive?
|
37
|
-
username = ask(
|
38
|
-
password = ask(
|
38
|
+
username = ask('Enter username: ')
|
39
|
+
password = ask('Enter password: ') { |q| q.echo = '*' }
|
39
40
|
|
40
41
|
if username.blank? || password.blank?
|
41
|
-
err(
|
42
|
+
err('Please enter username and password')
|
42
43
|
end
|
43
44
|
|
44
45
|
bootstrap.create_user(username, password)
|
45
46
|
else
|
46
|
-
bootstrap.create_user(
|
47
|
+
bootstrap.create_user('admin', SecureRandom.base64)
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
usage
|
51
|
-
desc
|
51
|
+
usage 'aws bootstrap bosh'
|
52
|
+
desc 'bootstrap full bosh deployment'
|
52
53
|
def bootstrap_bosh(config_file = nil)
|
53
54
|
target_required
|
54
55
|
err "To bootstrap BOSH, first log in to `#{config.target}'" unless logged_in?
|
@@ -59,9 +60,9 @@ module Bosh::Cli::Command
|
|
59
60
|
bootstrap = Bosh::Aws::BoshBootstrap.new(director, s3(config_file), self.options)
|
60
61
|
bootstrap.start
|
61
62
|
|
62
|
-
say
|
63
|
-
username = ask(
|
64
|
-
password = ask(
|
63
|
+
say 'For security purposes, please provide a username and password for BOSH Director'
|
64
|
+
username = ask('Enter username: ')
|
65
|
+
password = ask('Enter password: ') { |q| q.echo = '*' }
|
65
66
|
|
66
67
|
bootstrap.create_user(username, password)
|
67
68
|
|
@@ -72,8 +73,8 @@ module Bosh::Cli::Command
|
|
72
73
|
err "Unable to bootstrap bosh: #{e.message}"
|
73
74
|
end
|
74
75
|
|
75
|
-
usage
|
76
|
-
desc
|
76
|
+
usage 'aws generate micro_bosh'
|
77
|
+
desc 'generate micro_bosh.yml'
|
77
78
|
def create_micro_bosh_manifest(vpc_receipt_file, route53_receipt_file)
|
78
79
|
vpc_config = load_yaml_file(vpc_receipt_file)
|
79
80
|
route53_config = load_yaml_file(route53_receipt_file)
|
@@ -86,8 +87,8 @@ module Bosh::Cli::Command
|
|
86
87
|
write_yaml(manifest, manifest.file_name)
|
87
88
|
end
|
88
89
|
|
89
|
-
usage
|
90
|
-
desc
|
90
|
+
usage 'aws generate bosh'
|
91
|
+
desc 'generate bosh.yml deployment manifest'
|
91
92
|
def create_bosh_manifest(vpc_receipt_file, route53_receipt_file, bosh_rds_receipt_file)
|
92
93
|
target_required
|
93
94
|
|
@@ -102,8 +103,8 @@ module Bosh::Cli::Command
|
|
102
103
|
write_yaml(bosh_manifest, bosh_manifest.file_name)
|
103
104
|
end
|
104
105
|
|
105
|
-
usage
|
106
|
-
desc
|
106
|
+
usage 'aws generate bat'
|
107
|
+
desc 'generate bat.yml'
|
107
108
|
def create_bat_manifest(vpc_receipt_file, route53_receipt_file, stemcell_version, stemcell_name)
|
108
109
|
target_required
|
109
110
|
|
@@ -115,9 +116,9 @@ module Bosh::Cli::Command
|
|
115
116
|
write_yaml(manifest, manifest.file_name)
|
116
117
|
end
|
117
118
|
|
118
|
-
usage
|
119
|
-
desc
|
120
|
-
option
|
119
|
+
usage 'aws create'
|
120
|
+
desc 'create everything in migrations'
|
121
|
+
option '--trace', 'print all HTTP traffic'
|
121
122
|
def create(config_file = nil)
|
122
123
|
if !!options[:trace]
|
123
124
|
require 'logger'
|
@@ -127,34 +128,38 @@ module Bosh::Cli::Command
|
|
127
128
|
Bosh::Aws::Migrator.new(load_config(config_file)).migrate
|
128
129
|
end
|
129
130
|
|
130
|
-
usage
|
131
|
-
desc
|
131
|
+
usage 'aws create s3'
|
132
|
+
desc 'create only the s3 buckets'
|
132
133
|
def create_s3(config_file = nil)
|
133
|
-
Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version(
|
134
|
+
Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version('20130412192351')
|
134
135
|
end
|
135
136
|
|
136
|
-
usage
|
137
|
-
desc
|
137
|
+
usage 'aws create key_pairs'
|
138
|
+
desc 'creates only the key pairs'
|
138
139
|
def create_key_pairs(config_file = nil)
|
139
|
-
Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version(
|
140
|
+
Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version('20130412000811')
|
140
141
|
end
|
141
142
|
|
142
|
-
usage
|
143
|
-
desc
|
143
|
+
usage 'aws create route53 records'
|
144
|
+
desc 'creates only the Route 53 records'
|
144
145
|
def create_route53_records(config_file = nil)
|
145
|
-
Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version(
|
146
|
+
Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version('20130412181302')
|
146
147
|
end
|
147
148
|
|
148
|
-
usage
|
149
|
-
desc
|
149
|
+
usage 'aws create vpc'
|
150
|
+
desc 'creates only the VPC'
|
150
151
|
def create_vpc(config_file = nil)
|
151
|
-
Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version(
|
152
|
+
Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version('20130412004642')
|
152
153
|
end
|
153
154
|
|
154
|
-
usage
|
155
|
-
desc
|
155
|
+
usage 'aws destroy'
|
156
|
+
desc 'destroy everything in an AWS account'
|
156
157
|
def destroy(config_file = nil)
|
157
|
-
|
158
|
+
destroyer = Bosh::Aws::Destroyer.new(self)
|
159
|
+
config = load_config(config_file)
|
160
|
+
|
161
|
+
destroyer.ensure_not_production!(config)
|
162
|
+
destroyer.delete_all_elbs(config)
|
158
163
|
delete_all_ec2(config_file)
|
159
164
|
delete_all_ebs(config_file)
|
160
165
|
delete_all_rds_dbs(config_file)
|
@@ -170,15 +175,15 @@ module Bosh::Cli::Command
|
|
170
175
|
|
171
176
|
def s3(config_file)
|
172
177
|
config = load_config(config_file)
|
173
|
-
Bosh::Aws::S3.new(config[
|
178
|
+
Bosh::Aws::S3.new(config['aws'])
|
174
179
|
end
|
175
180
|
|
176
181
|
def delete_vpc(details_file)
|
177
182
|
details = load_yaml_file details_file
|
178
183
|
|
179
|
-
ec2 = Bosh::Aws::EC2.new(details[
|
180
|
-
vpc = Bosh::Aws::VPC.find(ec2, details[
|
181
|
-
route53 = Bosh::Aws::Route53.new(details[
|
184
|
+
ec2 = Bosh::Aws::EC2.new(details['aws'])
|
185
|
+
vpc = Bosh::Aws::VPC.find(ec2, details['vpc']['id'])
|
186
|
+
route53 = Bosh::Aws::Route53.new(details['aws'])
|
182
187
|
|
183
188
|
err("#{vpc.instances_count} instance(s) running in #{vpc.vpc_id} - delete them first") if vpc.instances_count > 0
|
184
189
|
|
@@ -193,30 +198,30 @@ module Bosh::Cli::Command
|
|
193
198
|
vpc.delete_vpc
|
194
199
|
dhcp_options.delete
|
195
200
|
|
196
|
-
if details[
|
197
|
-
details[
|
201
|
+
if details['key_pairs']
|
202
|
+
details['key_pairs'].each do |name|
|
198
203
|
ec2.remove_key_pair name
|
199
204
|
end
|
200
205
|
end
|
201
206
|
|
202
|
-
if details[
|
203
|
-
details[
|
204
|
-
ec2.release_elastic_ips(job[
|
205
|
-
if job[
|
206
|
-
route53.delete_record(job[
|
207
|
+
if details['elastic_ips']
|
208
|
+
details['elastic_ips'].values.each do |job|
|
209
|
+
ec2.release_elastic_ips(job['ips'])
|
210
|
+
if job['dns_record']
|
211
|
+
route53.delete_record(job['dns_record'], details['vpc']['domain'])
|
207
212
|
end
|
208
213
|
end
|
209
214
|
end
|
210
215
|
true # retryable block must yield true if we only want to retry on Exceptions
|
211
216
|
end
|
212
217
|
|
213
|
-
say
|
218
|
+
say 'deleted VPC and all dependencies'.make_green
|
214
219
|
end
|
215
220
|
|
216
221
|
def delete_all_vpcs(config_file)
|
217
222
|
config = load_config(config_file)
|
218
223
|
|
219
|
-
ec2 = Bosh::Aws::EC2.new(config[
|
224
|
+
ec2 = Bosh::Aws::EC2.new(config['aws'])
|
220
225
|
vpc_ids = ec2.vpcs.map { |vpc| vpc.id }
|
221
226
|
dhcp_options = []
|
222
227
|
|
@@ -224,7 +229,7 @@ module Bosh::Cli::Command
|
|
224
229
|
say("THIS IS A VERY DESTRUCTIVE OPERATION AND IT CANNOT BE UNDONE!\n".make_red)
|
225
230
|
say("VPCs:\n\t#{vpc_ids.join("\n\t")}")
|
226
231
|
|
227
|
-
if confirmed?(
|
232
|
+
if confirmed?('Are you sure you want to delete all VPCs?')
|
228
233
|
vpc_ids.each do |vpc_id|
|
229
234
|
vpc = Bosh::Aws::VPC.find(ec2, vpc_id)
|
230
235
|
err("#{vpc.instances_count} instance(s) running in #{vpc.vpc_id} - delete them first") if vpc.instances_count > 0
|
@@ -241,26 +246,26 @@ module Bosh::Cli::Command
|
|
241
246
|
dhcp_options.uniq(&:id).map(&:delete)
|
242
247
|
end
|
243
248
|
else
|
244
|
-
say(
|
249
|
+
say('No VPCs found')
|
245
250
|
end
|
246
251
|
end
|
247
252
|
|
248
253
|
def delete_all_key_pairs(config_file)
|
249
254
|
config = load_config(config_file)
|
250
|
-
ec2 = Bosh::Aws::EC2.new(config[
|
255
|
+
ec2 = Bosh::Aws::EC2.new(config['aws'])
|
251
256
|
|
252
|
-
if confirmed?(
|
253
|
-
say
|
257
|
+
if confirmed?('Are you sure you want to delete all SSH Keypairs?')
|
258
|
+
say 'Deleting all key pairs...'
|
254
259
|
ec2.remove_all_key_pairs
|
255
260
|
end
|
256
261
|
end
|
257
262
|
|
258
263
|
def delete_all_elastic_ips(config_file)
|
259
264
|
config = load_config(config_file)
|
260
|
-
ec2 = Bosh::Aws::EC2.new(config[
|
265
|
+
ec2 = Bosh::Aws::EC2.new(config['aws'])
|
261
266
|
|
262
|
-
if confirmed?(
|
263
|
-
say
|
267
|
+
if confirmed?('Are you sure you want to delete all Elastic IPs?')
|
268
|
+
say 'Releasing all elastic IPs...'
|
264
269
|
ec2.release_all_elastic_ips
|
265
270
|
end
|
266
271
|
end
|
@@ -268,25 +273,22 @@ module Bosh::Cli::Command
|
|
268
273
|
def delete_all_s3(config_file)
|
269
274
|
config = load_config(config_file)
|
270
275
|
|
271
|
-
|
272
|
-
|
273
|
-
s3 = Bosh::Aws::S3.new(config["aws"])
|
276
|
+
s3 = Bosh::Aws::S3.new(config['aws'])
|
274
277
|
bucket_names = s3.bucket_names
|
275
278
|
|
276
279
|
unless bucket_names.empty?
|
277
280
|
say("THIS IS A VERY DESTRUCTIVE OPERATION AND IT CANNOT BE UNDONE!\n".make_red)
|
278
281
|
say("Buckets:\n\t#{bucket_names.join("\n\t")}")
|
279
282
|
|
280
|
-
s3.empty if confirmed?(
|
283
|
+
s3.empty if confirmed?('Are you sure you want to empty and delete all buckets?')
|
281
284
|
else
|
282
|
-
say(
|
285
|
+
say('No S3 buckets found')
|
283
286
|
end
|
284
287
|
end
|
285
288
|
|
286
289
|
def delete_all_ec2(config_file)
|
287
290
|
config = load_config(config_file)
|
288
|
-
credentials = config[
|
289
|
-
check_instance_count(config)
|
291
|
+
credentials = config['aws']
|
290
292
|
ec2 = Bosh::Aws::EC2.new(credentials)
|
291
293
|
|
292
294
|
formatted_names = ec2.instance_names.map { |id, name| "#{name} (id: #{id})" }
|
@@ -294,43 +296,32 @@ module Bosh::Cli::Command
|
|
294
296
|
say("THIS IS A VERY DESTRUCTIVE OPERATION AND IT CANNOT BE UNDONE!\n".make_red)
|
295
297
|
say("Instances:\n\t#{formatted_names.join("\n\t")}")
|
296
298
|
|
297
|
-
if confirmed?(
|
298
|
-
say
|
299
|
+
if confirmed?('Are you sure you want to terminate all terminatable EC2 instances and their associated non-persistent EBS volumes?')
|
300
|
+
say 'Terminating instances and waiting for them to die...'
|
299
301
|
if !ec2.terminate_instances
|
300
|
-
say
|
302
|
+
say 'Warning: instances did not terminate yet after 100 retries'.make_red
|
301
303
|
end
|
302
304
|
end
|
303
305
|
else
|
304
|
-
say(
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
def delete_all_elbs(config_file)
|
309
|
-
config = load_config(config_file)
|
310
|
-
credentials = config["aws"]
|
311
|
-
elb = Bosh::Aws::ELB.new(credentials)
|
312
|
-
elb_names = elb.names
|
313
|
-
if elb_names.any? && confirmed?("Are you sure you want to delete all ELBs (#{elb_names.join(", ")})?")
|
314
|
-
elb.delete_elbs
|
306
|
+
say('No EC2 instances found')
|
315
307
|
end
|
316
308
|
end
|
317
309
|
|
318
310
|
def delete_server_certificates(config_file)
|
319
311
|
config = load_config(config_file)
|
320
|
-
credentials = config[
|
312
|
+
credentials = config['aws']
|
321
313
|
elb = Bosh::Aws::ELB.new(credentials)
|
322
314
|
certificates = elb.server_certificate_names
|
323
315
|
|
324
|
-
if certificates.any? && confirmed?("Are you sure you want to delete all server certificates? (#{certificates.join(
|
316
|
+
if certificates.any? && confirmed?("Are you sure you want to delete all server certificates? (#{certificates.join(', ')})")
|
325
317
|
elb.delete_server_certificates
|
326
|
-
say
|
318
|
+
say 'Server certificates deleted.'
|
327
319
|
end
|
328
320
|
end
|
329
321
|
|
330
322
|
def delete_all_rds_dbs(config_file)
|
331
323
|
config = load_config(config_file)
|
332
|
-
credentials = config[
|
333
|
-
check_instance_count(config)
|
324
|
+
credentials = config['aws']
|
334
325
|
rds = Bosh::Aws::RDS.new(credentials)
|
335
326
|
|
336
327
|
formatted_names = rds.database_names.map { |instance, db| "#{instance}\t(database_name: #{db})" }
|
@@ -338,9 +329,9 @@ module Bosh::Cli::Command
|
|
338
329
|
say("THIS IS A VERY DESTRUCTIVE OPERATION AND IT CANNOT BE UNDONE!\n".make_red)
|
339
330
|
say("Database Instances:\n\t#{formatted_names.join("\n\t")}")
|
340
331
|
|
341
|
-
if confirmed?(
|
332
|
+
if confirmed?('Are you sure you want to delete all databases?')
|
342
333
|
rds.delete_databases unless formatted_names.empty?
|
343
|
-
err(
|
334
|
+
err('not all rds instances could be deleted') unless all_rds_instances_deleted?(rds)
|
344
335
|
|
345
336
|
delete_all_rds_subnet_groups(config_file)
|
346
337
|
delete_all_rds_security_groups(config_file)
|
@@ -350,21 +341,21 @@ module Bosh::Cli::Command
|
|
350
341
|
|
351
342
|
def delete_all_rds_subnet_groups(config_file)
|
352
343
|
config = load_config(config_file)
|
353
|
-
credentials = config[
|
344
|
+
credentials = config['aws']
|
354
345
|
rds = Bosh::Aws::RDS.new(credentials)
|
355
346
|
rds.delete_subnet_groups
|
356
347
|
end
|
357
348
|
|
358
349
|
def delete_all_rds_security_groups(config_file)
|
359
350
|
config = load_config(config_file)
|
360
|
-
credentials = config[
|
351
|
+
credentials = config['aws']
|
361
352
|
rds = Bosh::Aws::RDS.new(credentials)
|
362
353
|
rds.delete_security_groups
|
363
354
|
end
|
364
355
|
|
365
356
|
def delete_all_ebs(config_file)
|
366
357
|
config = load_config(config_file)
|
367
|
-
credentials = config[
|
358
|
+
credentials = config['aws']
|
368
359
|
ec2 = Bosh::Aws::EC2.new(credentials)
|
369
360
|
check_volume_count(config)
|
370
361
|
|
@@ -372,15 +363,15 @@ module Bosh::Cli::Command
|
|
372
363
|
say("THIS IS A VERY DESTRUCTIVE OPERATION AND IT CANNOT BE UNDONE!\n".make_red)
|
373
364
|
say("It will delete #{ec2.volume_count} EBS volume(s)")
|
374
365
|
|
375
|
-
ec2.delete_volumes if confirmed?(
|
366
|
+
ec2.delete_volumes if confirmed?('Are you sure you want to delete all unattached EBS volumes?')
|
376
367
|
else
|
377
|
-
say(
|
368
|
+
say('No EBS volumes found')
|
378
369
|
end
|
379
370
|
end
|
380
371
|
|
381
372
|
def delete_all_security_groups(config_file)
|
382
373
|
config = load_config(config_file)
|
383
|
-
ec2 = Bosh::Aws::EC2.new(config[
|
374
|
+
ec2 = Bosh::Aws::EC2.new(config['aws'])
|
384
375
|
|
385
376
|
if confirmed?('Are you sure you want to delete all security groups?')
|
386
377
|
Bosh::Common.retryable(sleep: aws_retry_wait_time,
|
@@ -394,15 +385,15 @@ module Bosh::Cli::Command
|
|
394
385
|
|
395
386
|
def delete_all_route53_records(config_file)
|
396
387
|
config = load_config(config_file)
|
397
|
-
route53 = Bosh::Aws::Route53.new(config[
|
388
|
+
route53 = Bosh::Aws::Route53.new(config['aws'])
|
398
389
|
|
399
390
|
say("THIS IS A VERY DESTRUCTIVE OPERATION AND IT CANNOT BE UNDONE!\n".make_red)
|
400
391
|
|
401
392
|
omit_types = options[:omit_types] || %w[NS SOA]
|
402
393
|
if omit_types.empty?
|
403
|
-
msg =
|
394
|
+
msg = 'Are you sure you want to delete all records from Route 53?'
|
404
395
|
else
|
405
|
-
msg = "Are you sure you want to delete all but #{omit_types.join(
|
396
|
+
msg = "Are you sure you want to delete all but #{omit_types.join('/')} records from Route 53?"
|
406
397
|
end
|
407
398
|
|
408
399
|
route53.delete_all_records(omit_types: omit_types) if confirmed?(msg)
|
@@ -411,7 +402,7 @@ module Bosh::Cli::Command
|
|
411
402
|
def all_rds_instances_deleted?(rds)
|
412
403
|
return true if rds.databases.count == 0
|
413
404
|
(1..120).any? do |attempt|
|
414
|
-
say
|
405
|
+
say 'waiting for RDS deletion...'
|
415
406
|
sleep 10
|
416
407
|
rds.databases.each do |db_instance|
|
417
408
|
begin
|
@@ -426,30 +417,25 @@ module Bosh::Cli::Command
|
|
426
417
|
end
|
427
418
|
|
428
419
|
def deployment_manifest_state
|
429
|
-
@output_state[
|
420
|
+
@output_state['deployment_manifest'] ||= {}
|
430
421
|
end
|
431
422
|
|
432
423
|
def deployment_properties
|
433
|
-
deployment_manifest_state[
|
424
|
+
deployment_manifest_state['properties'] ||= {}
|
434
425
|
end
|
435
426
|
|
436
427
|
def flush_output_state(file_path)
|
437
428
|
File.open(file_path, 'w') { |f| f.write output_state.to_yaml }
|
438
429
|
end
|
439
430
|
|
440
|
-
def check_instance_count(config)
|
441
|
-
ec2 = Bosh::Aws::EC2.new(config["aws"])
|
442
|
-
err("#{ec2.instances_count} instance(s) running. This isn't a dev account (more than 20) please make sure you want to do this, aborting.") if ec2.instances_count > 20
|
443
|
-
end
|
444
|
-
|
445
431
|
def check_volume_count(config)
|
446
|
-
ec2 = Bosh::Aws::EC2.new(config[
|
432
|
+
ec2 = Bosh::Aws::EC2.new(config['aws'])
|
447
433
|
err("#{ec2.volume_count} volume(s) present. This isn't a dev account (more than 20) please make sure you want to do this, aborting.") if ec2.volume_count > 20
|
448
434
|
end
|
449
435
|
|
450
436
|
def default_config_file
|
451
437
|
File.expand_path(File.join(
|
452
|
-
File.dirname(__FILE__),
|
438
|
+
File.dirname(__FILE__), '..', '..', '..', '..', 'templates', 'aws_configuration_template.yml.erb'
|
453
439
|
))
|
454
440
|
end
|
455
441
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Bosh::Aws
|
2
|
+
class Destroyer
|
3
|
+
def initialize(ui)
|
4
|
+
@ui = ui
|
5
|
+
end
|
6
|
+
|
7
|
+
def ensure_not_production!(config)
|
8
|
+
ec2 = Bosh::Aws::EC2.new(config['aws'])
|
9
|
+
raise "#{ec2.instances_count} instance(s) running. This isn't a dev account (more than 20) please make sure you want to do this, aborting." if ec2.instances_count > 20
|
10
|
+
end
|
11
|
+
|
12
|
+
def delete_all_elbs(config)
|
13
|
+
credentials = config['aws']
|
14
|
+
elb = Bosh::Aws::ELB.new(credentials)
|
15
|
+
elb_names = elb.names
|
16
|
+
if elb_names.any? && @ui.confirmed?("Are you sure you want to delete all ELBs (#{elb_names.join(', ')})?")
|
17
|
+
elb.delete_elbs
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_cli_plugin_aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0.pre.
|
4
|
+
version: 1.5.0.pre.1209
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bosh_cli
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.5.0.pre.
|
21
|
+
version: 1.5.0.pre.1209
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.5.0.pre.
|
29
|
+
version: 1.5.0.pre.1209
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: bosh_aws_cpi
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.5.0.pre.
|
37
|
+
version: 1.5.0.pre.1209
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.5.0.pre.
|
45
|
+
version: 1.5.0.pre.1209
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bosh_cli_plugin_micro
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.5.0.pre.
|
53
|
+
version: 1.5.0.pre.1209
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.5.0.pre.
|
61
|
+
version: 1.5.0.pre.1209
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: bosh-stemcell
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 1.5.0.pre.
|
69
|
+
version: 1.5.0.pre.1209
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 1.5.0.pre.
|
77
|
+
version: 1.5.0.pre.1209
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: rspec-fire
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,7 +93,7 @@ dependencies:
|
|
93
93
|
version: '0'
|
94
94
|
description: ! 'BOSH plugin to easily create and delete an AWS VPC
|
95
95
|
|
96
|
-
|
96
|
+
669b45'
|
97
97
|
email: support@cloudfoundry.com
|
98
98
|
executables: []
|
99
99
|
extensions: []
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/bosh_cli_plugin_aws/bootstrap.rb
|
108
108
|
- lib/bosh_cli_plugin_aws/bosh_bootstrap.rb
|
109
109
|
- lib/bosh_cli_plugin_aws/bosh_manifest.rb
|
110
|
+
- lib/bosh_cli_plugin_aws/destroyer.rb
|
110
111
|
- lib/bosh_cli_plugin_aws/ec2.rb
|
111
112
|
- lib/bosh_cli_plugin_aws/elb.rb
|
112
113
|
- lib/bosh_cli_plugin_aws/micro_bosh_bootstrap.rb
|