Class: Aws::ECS::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext/aws_ecs_client.rb

Overview

rubocop:disable Style/ClassAndModuleChildren

Instance Method Summary collapse

Instance Method Details

#upsert_service(options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/core_ext/aws_ecs_client.rb', line 4

def upsert_service(options)
  active_services = describe_services(
    cluster: options[:cluster], services: [options[:service]]
  ).services.any? { |svc| svc.status == 'ACTIVE' }
  if active_services

    send(:update_service, options.tap { |o| o.delete(:load_balancers) })
  else
    options[:service_name] = options.delete(:service)
    send(:create_service, options)
  end
end