Class: Lono::Sets::Instances::Sync
- Includes:
- Summarize, Utils::Sure
- Defined in:
- lib/lono/sets/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 Summarize
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 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 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/sets/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 |
# File 'lib/lono/sets/instances/sync.rb', line 11 def run 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 " Nothing to be synced. IE: No stack instances need to be added or removed. If you want to update the\n stack set and update all stack instances instead, use the `lono sets deploy` command.\n EOL\n return\n end\n sure?(\"Are you sure you want to sync stack instances?\", long_desc(creates: creates, deletes: deletes))\n\n # Note: Not calling update_stack_instances because after deleting stacks it instances in in a weird state\n # where an update_stack_instances fails. Can reproduce this by deleting stacks and then trying an update_stack_instances\n # with the AWS CLI. In theory, we never really should have to call update_stack_instances anyway because\n # updating the stack set at the parent level kicks off an update_stack_instances automatically.\n operation_id = execute(:create_stack_instances, creates)\n summarize(operation_id) if operation_id\n if @options[:delete]\n operation_id = execute(:delete_stack_instances, deletes)\n summarize(operation_id) if operation_id\n end\nend\n" |