From 11180be4e8323b385eb6940ead22c2e5b598e0a1 Mon Sep 17 00:00:00 2001 From: Thanh Le Date: Wed, 30 Nov 2022 17:23:05 +0700 Subject: [PATCH] CPD-7592 keep standard tags when updating Change: patch Purpose: maintenance --- lib/moonshot/stack.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/moonshot/stack.rb b/lib/moonshot/stack.rb index fb9e78c1..e66a625b 100644 --- a/lib/moonshot/stack.rb +++ b/lib/moonshot/stack.rb @@ -39,6 +39,7 @@ def update(dry_run:, force:) raise "No stack found #{@name.blue}!" unless stack_exists? change_set = ChangeSet.new(new_change_set, @name) + wait_for_change_set(change_set) return unless change_set.valid? @@ -94,6 +95,12 @@ def outputs .to_h end + def existing_tags + get_stack(@name) + .tags + .map { |o| { key: o.key, value: o.value } } + end + def exists? cf_client.describe_stacks(stack_name: @name) true @@ -235,6 +242,7 @@ def new_change_set parameters: @config.parameters.values.map(&:to_cf), tags: make_tags } + if @config.template_s3_bucket parameters[:template_url] = upload_template_to_s3 else @@ -301,7 +309,7 @@ def make_tags default_tags << { key: @config.additional_tag, value: @name } end - default_tags + @config.extra_tags + (default_tags + @config.extra_tags + existing_tags).uniq! end def format_event(event)