Class: Ufo::LogGroup
- Inherits:
-
Object
- Object
- Ufo::LogGroup
- Includes:
- AwsService
- Defined in:
- lib/ufo/log_group.rb
Instance Method Summary collapse
- #create ⇒ Object
- #create_log_group(log_group_name) ⇒ Object
-
#initialize(task_definition, options) ⇒ LogGroup
constructor
A new instance of LogGroup.
- #task_def_path ⇒ Object
Methods included from AwsService
#cloudformation, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb
Constructor Details
#initialize(task_definition, options) ⇒ LogGroup
Returns a new instance of LogGroup.
7 8 9 |
# File 'lib/ufo/log_group.rb', line 7 def initialize(task_definition, ) @task_definition, @options = task_definition, end |
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ufo/log_group.rb', line 11 def create puts "Ensuring log group for #{@task_definition.color(:green)} task definition exists" return if @options[:noop] Ufo.check_task_definition!(@task_definition) 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"] puts "Log group name: #{log_group_name}" rescue NoMethodError # silence when the logConfiguration is not specified end create_log_group(log_group_name) if log_group_name end end |
#create_log_group(log_group_name) ⇒ Object
29 30 31 32 33 |
# File 'lib/ufo/log_group.rb', line 29 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 |