From 73d613116cc62745ccf87e3dd8aaeff59b260841 Mon Sep 17 00:00:00 2001 From: lethanh273 Date: Thu, 1 Dec 2022 09:37:53 +0000 Subject: [PATCH] cpd-7592 keep standard tags with moonshot update --- lib/moonshot/stack.rb | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/lib/moonshot/stack.rb b/lib/moonshot/stack.rb index f1a40c74..e66a625b 100644 --- a/lib/moonshot/stack.rb +++ b/lib/moonshot/stack.rb @@ -95,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 @@ -236,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,32 +308,8 @@ def make_tags if @config.additional_tag default_tags << { key: @config.additional_tag, value: @name } end - default_tags + @config.extra_tags + standard_tags - end - def standard_tags - env = if @config.environment_name.include?('dev') - 'development' - elsif @config.environment_name.include?('test') - 'staging' - else - 'production' - end - - standard_tags = [ - { key: 'acquia:bu', value: 'dc' }, - { key: 'acquia:stage', value: "cloud-data-#{@name}"}, - { key: 'acquia:created_for', value: 'cloud-data'}, - { key: 'acquia:created_by', value: 'cloud-data-service'}, - { key: 'acquia:environment', value: env} - ] - - unless env == 'production' - standard_tags << { key: 'acquia:expiry', value: '9999-01-01' } - standard_tags << { key: 'acquia:consumer', value: 'cloud-data' } - end - - standard_tags + (default_tags + @config.extra_tags + existing_tags).uniq! end def format_event(event) @@ -389,4 +372,3 @@ def execute_change_set(change_set) end end end -