Class: Lono::Sets::Instances::Delete
- Includes:
- AwsServices, Utils::Sure
- Defined in:
- lib/lono/sets/instances/delete.rb
Instance Method Summary collapse
- #accounts ⇒ Object
-
#initialize(options = {}) ⇒ Delete
constructor
A new instance of Delete.
- #long_desc ⇒ Object
- #regions ⇒ Object
- #run ⇒ Object
- #validate! ⇒ Object
Methods included from Utils::Sure
Methods included from AwsServices
#cfn, #ec2, #iam, #s3, #s3_presigner, #s3_resource, #sts
Methods included from AwsServices::Helper
#rollback_complete?, #testing_update?
Methods included from AwsServices::StackSet
#find_stack_set, #stack_set_exists?
Methods included from AwsServices::Stack
Methods inherited from Base
Methods inherited from Base
#build_options, #exit_unless_updatable!, #operation_preferences
Methods inherited from Cfn::Base
#capabilities, #command_with_iam, #continue_update_rollback, #continue_update_rollback_sure?, #delete_rollback_stack, #exit_unless_updatable!, #generate_all, #notification_arns, #pretty_path, #prompt_for_iam, #quit, #rerun_with_iam?, #set_template_url!, #show_options, #stack_status, #starting_message, #status, #tags
Methods inherited from AbstractBase
Methods included from Blueprint::Root
#find_blueprint_root, #set_blueprint_root
Constructor Details
#initialize(options = {}) ⇒ Delete
Returns a new instance of Delete.
6 7 8 9 |
# File 'lib/lono/sets/instances/delete.rb', line 6 def initialize(={}) @options = @stack = [:stack] end |
Instance Method Details
#accounts ⇒ Object
61 62 63 |
# File 'lib/lono/sets/instances/delete.rb', line 61 def accounts @options[:all] ? stack_instances.map(&:account).uniq : @options[:accounts] end |
#long_desc ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lono/sets/instances/delete.rb', line 41 def long_desc total = accounts.size * regions.size <<~EOL These stack instances will be deleted: accounts: #{accounts.join(',')} regions: #{regions.join(',')} Number of stack instances to be deleted: #{total} EOL end |
#regions ⇒ Object
65 66 67 |
# File 'lib/lono/sets/instances/delete.rb', line 65 def regions @options[:all] ? stack_instances.map(&:region).uniq : @options[:regions] end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lono/sets/instances/delete.rb', line 11 def run validate! sure?("Are you sure you want to delete the #{@stack} instances?", long_desc) # delete_stack_instances resp has operation_id # Could also use that to poll for status with the list_stack_set_operation_results # api. Currently, Instance::Status class not using this info. If we need will add the logic. resp = cfn.delete_stack_instances( = { stack_set_name: @stack, accounts: accounts, regions: regions, retain_stacks: false, } ) operation_id = resp.operation_id # Status tailing handled by caller o = @options.merge( filter: requested, start_on_outdated: false, operation_id: operation_id, ) Lono::Sets::Status::Instance::Base.show_time_progress = true Lono::Sets::Status::Instance::Base.delay_factor = accounts.size * regions.size instances_status = Status.new(o) instances_status.run(to: "deleted") unless @options[:noop] # returns success: true or false end |
#validate! ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/lono/sets/instances/delete.rb', line 53 def validate! invalid = (regions.blank? || accounts.blank?) && !@options[:all] if invalid puts "ERROR: You must provide --accounts and --regions or --all.".color(:red) exit 1 end end |