Class: KumoKi::KMS
- Inherits:
-
Object
- Object
- KumoKi::KMS
- Defined in:
- lib/kumo_ki.rb
Instance Method Summary collapse
Instance Method Details
#client ⇒ Object
8 9 10 11 12 |
# File 'lib/kumo_ki.rb', line 8 def client @client ||= Aws::KMS::Client.new( region: ENV['AWS_REGION'] || 'us-east-1', ) end |
#decrypt(cipher_text) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/kumo_ki.rb', line 14 def decrypt(cipher_text) client.decrypt({ ciphertext_blob: Base64.decode64(cipher_text) }).plaintext rescue => e raise KumoKi::DecryptionError.new("There was a problem decrypting your secrets: #{e.}") end |
#encrypt_for(env_name, plain_text) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/kumo_ki.rb', line 22 def encrypt_for(env_name, plain_text) Base64.encode64(client.encrypt({ key_id: key_for_environment(env_name), plaintext: plain_text, }).ciphertext_blob) end |