Class: Awful::Kms

Inherits:
Cli show all
Defined in:
lib/awful/kms.rb

Constant Summary collapse

COLORS =
{
  Enabled:         :green,
  PendingDeletion: :red,
}

Instance Method Summary collapse

Methods inherited from Cli

#initialize

Constructor Details

This class inherits a constructor from Awful::Cli

Instance Method Details

#get(id) ⇒ Object



81
82
83
84
85
# File 'lib/awful/kms.rb', line 81

def get(id)
  kms.describe_key(key_id: id_or_alias(id))..output do |key|
    puts YAML.dump(stringify_keys(key.to_hash))
  end
end

#lsObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/awful/kms.rb', line 65

def ls
  paginate(:keys) do |marker|
    kms.list_keys(marker: marker)
  end.output do |keys|
    if options[:long]
      print_table keys.map { |k|
        key = kms.describe_key(key_id: k.key_id).
        [ aliases_hash.fetch(k.key_id, '-'), k.key_id, color(key.key_state), key.creation_date ]
      }.sort
    else
      puts keys.map(&:key_id)
    end
  end
end

#policy(id) ⇒ Object



89
90
91
92
93
# File 'lib/awful/kms.rb', line 89

def policy(id)
  kms.get_key_policy(key_id: id_or_alias(id), policy_name: options[:name]).policy.output do |policy|
    puts policy
  end
end