Class: Lono::SetInstances::Changeable
- Inherits:
-
Base
- Object
- AbstractBase
- Cfn::Base
- Lono::Sets::Base
- Base
- Lono::SetInstances::Changeable
- Includes:
- AwsServices, Utils::Sure
- Defined in:
- lib/lono/set_instances/changeable.rb
Instance Method Summary collapse
- #accounts ⇒ Object
-
#initialize(options = {}) ⇒ Changeable
constructor
A new instance of Changeable.
- #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 Lono::Sets::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 = {}) ⇒ Changeable
Returns a new instance of Changeable.
6 7 8 9 |
# File 'lib/lono/set_instances/changeable.rb', line 6 def initialize(={}) super # need conventions so config lookup will work @regions, @accounts = [], [] end |
Instance Method Details
#accounts ⇒ Object
45 46 47 |
# File 'lib/lono/set_instances/changeable.rb', line 45 def accounts @options[:all] ? stack_instances.map(&:account).uniq : @options[:accounts] end |
#regions ⇒ Object
49 50 51 |
# File 'lib/lono/set_instances/changeable.rb', line 49 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 |
# File 'lib/lono/set_instances/changeable.rb', line 11 def run validate! unless stack_set_exists?(@stack) puts "ERROR: Cannot update a stack set because #{@stack} does not exists.".color(:red) return end exit_unless_updatable! = { stack_set_name: @stack, accounts: accounts, regions: regions, } begin resp = perform() rescue Aws::CloudFormation::Errors::ValidationError => e # IE: Aws::CloudFormation::Errors::ValidationError: Region eu-north-1 is not supported puts "#{e.class}: #{e.}".color(:red) exit 1 end return true if @options[:noop] Lono::Sets::Waiter.new(@options).run(resp[:operation_id]) end |
#validate! ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/lono/set_instances/changeable.rb', line 37 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 |