Class: Ufo::LogGroup
Instance Attribute Summary
Attributes inherited from CLI::Base
#task_definition
Instance Method Summary
collapse
#acm, #applicationautoscaling, #aws_options, #cloudformation, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #find_stack, #ssm_client, #stack_resources, #status, #task_definition_arns, #waf_client
Methods inherited from CLI::Base
#initialize
#sure?
#pretty_home, #pretty_path, #pretty_time
#logger
Methods included from Concerns
#build, #deploy, #info, #ps
#names
Constructor Details
This class inherits a constructor from Ufo::CLI::Base
Instance Method Details
#check_task_definition_exists! ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/ufo/log_group.rb', line 36
def check_task_definition_exists!
return if File.exist?(task_def_path)
logger.error "ERROR: Unable to find the task definition at #{task_def_path}.".color(:red)
logger.error " Please double check that it was built correctly with:\n\n ufo build\n\n EOL\n exit 1\nend\n"
|
#create ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/ufo/log_group.rb', line 7
def create
logger.debug "Ensuring log group for #{@task_definition.name.color(:green)} task definition exists"
return if @options[:noop]
return if @options[:rollback]
check_task_definition_exists!
task_def = JSON.load(IO.read(task_def_path))
task_def["containerDefinitions"].each do |container_def|
begin
log_group_name = container_def["logConfiguration"]["options"]["awslogs-group"]
logger.debug "Log group name: #{log_group_name}"
rescue NoMethodError
end
create_log_group(log_group_name) if log_group_name
end
end
|
#create_log_group(log_group_name) ⇒ Object
26
27
28
29
30
|
# File 'lib/ufo/log_group.rb', line 26
def create_log_group(log_group_name)
resp = cloudwatchlogs.describe_log_groups(log_group_name_prefix: log_group_name)
exists = resp.log_groups.find { |lg| lg.log_group_name == log_group_name }
cloudwatchlogs.create_log_group(log_group_name: log_group_name) unless exists
end
|
#task_def_path ⇒ Object
32
33
34
|
# File 'lib/ufo/log_group.rb', line 32
def task_def_path
"#{Ufo.root}/.ufo/output/task_definition.json"
end
|