Class: AwsRotate::Keys

Inherits:
Base
  • Object
show all
Defined in:
lib/aws_rotate/keys.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from AwsServices

#iam, #sts

Constructor Details

This class inherits a constructor from AwsRotate::Base

Instance Method Details

#filter_match?(profile) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/aws_rotate/keys.rb', line 13

def filter_match?(profile)
  return true if @options[:select].nil? && @options[:reject].nil?

  unless @options[:reject].nil?
    reject_list = @options[:reject]
    reject_list.map! { |f|  Regexp.new(f) }
    rejected = !!reject_list.detect do |regexp|
      profile =~ regexp
    end
    return false if rejected
  end

  return true if @options[:select].nil?

  select_list = @options[:select]
  select_list.map! { |f|  Regexp.new(f) }
  selected = !!select_list.detect do |regexp|
    profile =~ regexp
  end
  selected
end

#runObject



3
4
5
6
7
8
9
10
11
# File 'lib/aws_rotate/keys.rb', line 3

def run
  list = List.new(@options)
  list.profiles.each do |profile|
    next unless filter_match?(profile)

    ENV['AWS_PROFILE'] = profile
    Key.new(@options).run
  end
end