Class: Lono::SetInstances::Deploy
- Inherits:
-
Changeable
- Object
- AbstractBase
- Cfn::Base
- Lono::Sets::Base
- Base
- Changeable
- Lono::SetInstances::Deploy
- Defined in:
- lib/lono/set_instances/deploy.rb
Instance Method Summary collapse
- #deploy(type, changes) ⇒ Object
- #lono_command(klass) ⇒ Object
- #run ⇒ Object
- #run_action(type, account, regions) ⇒ Object
- #stack_instance_exists?(account, region) ⇒ Boolean
Methods inherited from Changeable
#accounts, #initialize, #regions, #validate!
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
#accounts, #regions, #requested, #stack_instances
Methods inherited from Lono::Sets::Base
#build_options, #exit_unless_updatable!, #initialize, #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
#initialize, #reinitialize, #template_path
Methods included from Blueprint::Root
#find_blueprint_root, #set_blueprint_root
Constructor Details
This class inherits a constructor from Lono::SetInstances::Changeable
Instance Method Details
#deploy(type, changes) ⇒ Object
20 21 22 23 24 |
# File 'lib/lono/set_instances/deploy.rb', line 20 def deploy(type, changes) changes.each do |account, regions| run_action(type, account, regions) end end |
#lono_command(klass) ⇒ Object
38 39 40 41 |
# File 'lib/lono/set_instances/deploy.rb', line 38 def lono_command(klass) klass = klass.to_s klass.split('::').map(&:underscore).join(' ') end |
#run ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/lono/set_instances/deploy.rb', line 3 def run # computes whether create or update should be ran for stack instances within each account updates, creates = Hash.new([]), Hash.new([]) accounts.each do |account| regions.each do |region| if stack_instance_exists?(account, region) updates[account] += [region] # += [item] works, << item doesnt seem to work else creates[account] += [region] # += [item] works, << item doesnt seem to work end end end deploy(:create, creates) deploy(:update, updates) end |
#run_action(type, account, regions) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lono/set_instances/deploy.rb', line 26 def run_action(type, account, regions) klass = "Lono::SetInstances::#{type.to_s.camelize}" klass = klass.constantize command = lono_command(klass) puts "Running #{command.color(:green)} on account: #{account} regions: #{regions.join(',')}" = .dup [:accounts] = [account] [:regions] = regions klass.new().run end |
#stack_instance_exists?(account, region) ⇒ Boolean
43 44 45 46 47 48 49 |
# File 'lib/lono/set_instances/deploy.rb', line 43 def stack_instance_exists?(account, region) existing = stack_instances.map do |summary| [summary.account, summary.region] end intersect = existing & [[account, region]] !intersect.empty? end |