Class: Jets::Commands::Clean::Log

Inherits:
Base
  • Object
show all
Extended by:
Memoist
Includes:
AwsServices
Defined in:
lib/jets/commands/clean/log.rb

Instance Method Summary collapse

Methods included from AwsServices

#apigateway, #cfn, #lambda, #logs, #s3, #s3_resource, #sns, #sqs, #sts

Methods included from AwsServices::StackStatus

#lookup, #stack_exists?, #stack_in_progress?

Methods inherited from Base

autocomplete, banner, dispatch, eager_load!, help_list, inherited, klass_from_namespace, namespace_from_class, namespaced_commands, perform, special_class_map, subclasses

Instance Method Details

#cleanObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jets/commands/clean/log.rb', line 16

def clean
  are_you_sure?("delete CloudWatch logs")

  say "Removing CloudWatch logs for #{prefix_guess}..."
  log_groups.each do |g|
    next if keep_log_group?(g.log_group_name)
    logs.delete_log_group(log_group_name: g.log_group_name) unless @options[:noop]
    say "Removed log group: #{g.log_group_name}"
  end
  say "Removed CloudWatch logs for #{prefix_guess}"
end

#clean_deploysObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/jets/commands/clean/log.rb', line 28

def clean_deploys
  groups = deploy_log_groups.sort_by do |g|
    g.log_group_name
  end
  # Keep the last 2 recent log groups so we can see the deleted logic
  groups = groups[0..-3]
  groups.each do |g|
    logs.delete_log_group(log_group_name: g.log_group_name) unless @options[:noop]
  end
end

#deploy_log_groupsObject



39
40
41
42
43
44
# File 'lib/jets/commands/clean/log.rb', line 39

def deploy_log_groups
  log_groups.select do |g|
    !keep_log_group?(g.log_group_name) &&
    g.log_group_name.include?('jets-base-path')
  end
end