Sha256: 331e052dcc213f42e2bb845fd719856e39b677472a99f8b1c02c1af29a6e1e0f

Contents?: true

Size: 1.83 KB

Versions: 13

Compression:

Stored size: 1.83 KB

Contents

class Ufo::Stack
  module Helper
    include Ufo::AwsService
    include Ufo::Util
    extend Memoist

    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

    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

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

    def status
      Status.new(@stack_name)
    end
    memoize :status
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ufo-4.6.3 lib/ufo/stack/helper.rb
ufo-4.6.2 lib/ufo/stack/helper.rb
ufo-4.6.1 lib/ufo/stack/helper.rb
ufo-4.6.0 lib/ufo/stack/helper.rb
ufo-4.5.11 lib/ufo/stack/helper.rb
ufo-4.5.10 lib/ufo/stack/helper.rb
ufo-4.5.9 lib/ufo/stack/helper.rb
ufo-4.5.8 lib/ufo/stack/helper.rb
ufo-4.5.7 lib/ufo/stack/helper.rb
ufo-4.5.6 lib/ufo/stack/helper.rb
ufo-4.5.5 lib/ufo/stack/helper.rb
ufo-4.5.4 lib/ufo/stack/helper.rb
ufo-4.5.3 lib/ufo/stack/helper.rb