Skip to content

Commit

Permalink
cpd-7592 keep standard tags with moonshot update
Browse files Browse the repository at this point in the history
  • Loading branch information
lethanh273 authored Dec 1, 2022
1 parent 6b2fa6f commit 73d6131
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions lib/moonshot/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -389,4 +372,3 @@ def execute_change_set(change_set)
end
end
end

0 comments on commit 73d6131

Please sign in to comment.