Class: Ufo::LogGroup
- Includes:
- AwsServices
- Defined in:
- lib/ufo/log_group.rb
Instance Attribute Summary
Attributes inherited from CLI::Base
Instance Method Summary collapse
- #check_task_definition_exists! ⇒ Object
- #create ⇒ Object
- #create_log_group(log_group_name) ⇒ Object
- #task_def_path ⇒ Object
Methods included from AwsServices
#acm, #applicationautoscaling, #aws_options, #cfn, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #s3, #ssm_client, #waf_client
Methods included from AwsServices::Concerns
#find_stack, #find_stack_resources, #stack_resources, #status, #task_definition_arns
Methods inherited from CLI::Base
Methods included from Utils::Sure
Methods included from Utils::Pretty
#pretty_home, #pretty_path, #pretty_time
Methods included from Utils::Logging
Methods included from Concerns
Methods included from Concerns::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 <<~EOL Please double check that it was built correctly with: ufo build EOL exit 1 end |
#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] # dont need to create log group because previously deployed 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 # 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
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 |