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
# File 'lib/ufo/stack/helper.rb', line 19

def adjust_stack_name(cluster, service)
  if settings[:stack_naming] != "append_env"
    puts "WARN: In ufo v4.4 the environment name 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: http://ufoships.com/docs/upgrading/upgrade4.4/".color(:yellow)
    puts "To get rid of this warning you can add `stack_naming: append_env` to your `.ufo/settings.yml config. New versions of ufo init does this automatically."
    puts "Pausing for 20 seconds."
    sleep 20
  end

  parts = if settings[:stack_naming] == "append_env"
    [service, cluster, Ufo.env_extra]
  else
    # legacy, to be removed in next major version
    [cluster, service, Ufo.env_extra]
  end
  parts.reject {|x| x==''}.compact.join('-') # stack_name
end

#cfnObject



36
37
38
# File 'lib/ufo/stack/helper.rb', line 36

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



40
41
42
# File 'lib/ufo/stack/helper.rb', line 40

def status
  Status.new(@stack_name)
end