Sha256: 9799830a2cd8cdd808222ed8eeeee2633911e984517910577895a6c1ca770a73

Contents?: true

Size: 1.58 KB

Versions: 31

Compression:

Stored size: 1.58 KB

Contents

module Ufo
  class Info < Base
    def run
      unless service
        puts no_service_message
        return
      end
      puts "Resources:"
      stack_resources.each do |r|
        # pp r
        puts "#{r.logical_resource_id} - #{r.resource_type}:".color(:green)
        puts "  #{r.physical_resource_id}"
      end
    end

    # Passing in service so method can be used else where.
    def load_balancer(service)
      load_balancer = service.load_balancers.first
      return unless load_balancer

      resp = elb.describe_target_groups(
        target_group_arns: [load_balancer.target_group_arn]
      )
      target_group = resp.target_groups.first
      load_balancer_arn = target_group.load_balancer_arns.first # assume first only

      resp = elb.describe_load_balancers(load_balancer_arns: [load_balancer_arn])
      resp.load_balancers.first
    end
    memoize :load_balancer

    def service
      return unless stack

      service = stack_resources.find { |r| r.resource_type == "AWS::ECS::Service" }
      arn = service.physical_resource_id
      resp = ecs.describe_services(services: [arn], cluster: @cluster)
      resp.services.first
    end
    memoize :service

    def stack
      find_stack(@stack_name)
    end
    memoize :stack

    def route53_dns
      return unless stack

      output = stack.outputs.find do |o|
        o.output_key == "Route53Dns"
      end
      output.output_value if output
    end

    def stack_resources
      resp = cloudformation.describe_stack_resources(stack_name: @stack_name)
      resp.stack_resources
    end
    memoize :stack_resources
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
ufo-5.0.7 lib/ufo/info.rb
ufo-5.0.6 lib/ufo/info.rb
ufo-5.0.5 lib/ufo/info.rb
ufo-5.0.4 lib/ufo/info.rb
ufo-5.0.3 lib/ufo/info.rb
ufo-5.0.2 lib/ufo/info.rb
ufo-5.0.1 lib/ufo/info.rb
ufo-5.0.0 lib/ufo/info.rb
ufo-4.6.3 lib/ufo/info.rb
ufo-4.6.2 lib/ufo/info.rb
ufo-4.6.1 lib/ufo/info.rb
ufo-4.6.0 lib/ufo/info.rb
ufo-4.5.11 lib/ufo/info.rb
ufo-4.5.10 lib/ufo/info.rb
ufo-4.5.9 lib/ufo/info.rb
ufo-4.5.8 lib/ufo/info.rb
ufo-4.5.7 lib/ufo/info.rb
ufo-4.5.6 lib/ufo/info.rb
ufo-4.5.5 lib/ufo/info.rb
ufo-4.5.4 lib/ufo/info.rb