Module: Ufo::Stack::Helper

Extended by:
Memoist
Includes:
AwsService, Util
Included in:
Apps, Apps::CfnMap, Base, Ufo::Stack, Context
Defined in:
lib/ufo/stack/helper.rb

Instance Method Summary collapse

Methods included from Util

#default_cluster, #display_params, #execute, #pretty_time, #settings, #task_definition_arns, #user_params

Methods included from AwsService

#cloudformation, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb

Instance Method Details

#adjust_stack_name(cluster, service) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ufo/stack/helper.rb', line 19

def adjust_stack_name(cluster, service)
  if settings[:stack_naming].nil?
    puts "WARN: In ufo v4.5 the UFO_ENV value gets appends to the end of the CloudFormation stack name.  This means a new stack gets created. You must upgrade to using the new stack and delete the old stack manually.  More info: https://ufoships.com/docs/upgrading/upgrade4.5/".color(:yellow)
    puts "To get rid of this warning you can add `stack_naming: append_ufo_env` to your `.ufo/settings.yml config. New versions of ufo init do this automatically."
    puts "Pausing for 20 seconds."
    sleep 20
  end

  parts = case settings[:stack_naming]
  when "prepend_cluster" # ufo v4.3 and below
    [cluster, service, Ufo.env_extra] # legacy
  when "append_env", "append_cluster" # ufo v4.5
    # append_env will be removed in the next major version in favor of append_cluster to avoid confusion with
    # append_ufo_env
    [service, cluster, Ufo.env_extra]
  when "append_nothing", "prepend_nothing"
    [service, Ufo.env_extra]
  else # new default. ufo v4.5 and above
    [service, Ufo.env, Ufo.env_extra]
  end
  parts.reject {|x| x==''}.compact.join('-') # stack_name
end

#cfnObject



42
43
44
# File 'lib/ufo/stack/helper.rb', line 42

def cfn
  Ufo::Setting::Profile.new(:cfn, settings[:cfn_profile]).data
end

#find_stack(stack_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ufo/stack/helper.rb', line 7

def find_stack(stack_name)
  resp = cloudformation.describe_stacks(stack_name: stack_name)
  resp.stacks.first
rescue Aws::CloudFormation::Errors::ValidationError => e
  # example: Stack with id demo-web does not exist
  if e.message =~ /Stack with/ && e.message =~ /does not exist/
    nil
  else
    raise
  end
end

#statusObject



46
47
48
# File 'lib/ufo/stack/helper.rb', line 46

def status
  Status.new(@stack_name)
end