class EcsDeployCli::DSL::Container

Public Class Methods

new(name, config) click to toggle source
# File lib/ecs_deploy_cli/dsl/container.rb, line 10
def initialize(name, config)
  @config = config
  _options[:name] = name.to_s
end

Public Instance Methods

as_definition() click to toggle source
# File lib/ecs_deploy_cli/dsl/container.rb, line 57
def as_definition
  {
    cpu: 0,
    mount_points: [],
    port_mappings: [],
    volumes_from: [],
    memory_reservation: nil,
    essential: true
  }.merge(_options)
end
cloudwatch_logs(value) click to toggle source
# File lib/ecs_deploy_cli/dsl/container.rb, line 46
def cloudwatch_logs(value)
  _options[:log_configuration] = {
    log_driver: 'awslogs',
    options: {
      'awslogs-group' => "/ecs/#{value}",
      'awslogs-stream-prefix' => 'ecs',
      'awslogs-region' => @config[:aws_region]
    }
  }
end
command(*command) click to toggle source
# File lib/ecs_deploy_cli/dsl/container.rb, line 15
def command(*command)
  _options[:command] = command
end
env(key:, value:) click to toggle source
# File lib/ecs_deploy_cli/dsl/container.rb, line 23
def env(key:, value:)
  (_options[:environment] ||= []) << { name: key, value: value }
end
expose(**options) click to toggle source
# File lib/ecs_deploy_cli/dsl/container.rb, line 31
def expose(**options)
  (_options[:port_mappings] ||= []) << options
end
load_envs(name) click to toggle source
# File lib/ecs_deploy_cli/dsl/container.rb, line 19
def load_envs(name)
  _options[:environment] = (_options[:environment] || []) + YAML.safe_load(File.open(name), symbolize_names: true)
end
memory(limit:, reservation:) click to toggle source
# File lib/ecs_deploy_cli/dsl/container.rb, line 35
def memory(limit:, reservation:)
  _options[:memory] = limit
  _options[:memory_reservation] = reservation
end
merge(other) click to toggle source
# File lib/ecs_deploy_cli/dsl/container.rb, line 40
def merge(other)
  other_options = other._options
  other_options.delete(:name)
  _options.merge!(other_options)
end
secret(key:, value:) click to toggle source
# File lib/ecs_deploy_cli/dsl/container.rb, line 27
def secret(key:, value:)
  (_options[:secrets] ||= []) << { name: key, value_from: "arn:aws:ssm:#{@config[:aws_region]}:#{@config[:aws_profile_id]}:parameter/#{value}" }
end