Class: Lono::SetInstances::Sync
- Inherits:
-
Base
- Object
- AbstractBase
- Cfn::Base
- Lono::Sets::Base
- Base
- Lono::SetInstances::Sync
- Includes:
- Lono::Sets::Summarize, Utils::Sure
- Defined in:
- lib/lono/set_instances/sync.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Sync
constructor
A new instance of Sync.
- #run ⇒ Object
Methods included from Utils::Sure
Methods included from Lono::Sets::Summarize
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 = {}) ⇒ Sync
Returns a new instance of Sync.
6 7 8 9 |
# File 'lib/lono/set_instances/sync.rb', line 6 def initialize(={}) super # need conventions so config lookup will work @regions, @accounts = [], [] end |
Instance Method Details
#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 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lono/set_instances/sync.rb', line 11 def run puts "DEPRECATED: The sync command is deprecated, in favor of the deploy command.".color(:yellow) puts "Found more success with an explicit approach. sync may be removed in future versions of lono." unless stack_set_exists?(@stack) puts "ERROR: Cannot update a stack set because #{@stack} does not exists.".color(:red) return end exit_unless_updatable! validate! existing = stack_instances.map do |summary| [summary.account, summary.region] end creates = requested - existing deletes = existing - requested if creates.empty? and deletes.empty? puts <<~EOL Nothing to be synced. IE: No stack instances need to be added or removed. If you want to update the stack set and update all stack instances instead, use the `lono sets deploy` command. EOL return end sure?("Are you sure you want to sync stack instances?", long_desc(creates: creates, deletes: deletes)) # Note: Not calling update_stack_instances because after deleting stacks it instances in in a weird state # where an update_stack_instances fails. Can reproduce this by deleting stacks and then trying an update_stack_instances # with the AWS CLI. In theory, we never really should have to call update_stack_instances anyway because # updating the stack set at the parent level kicks off an update_stack_instances automatically. operation_id = execute(:create_stack_instances, creates) summarize(operation_id) if operation_id if @options[:delete] operation_id = execute(:delete_stack_instances, deletes) summarize(operation_id) if operation_id end end |