Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gemspec #6

Merged
merged 1 commit into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org/'

gem 'aws-sdk', '~> 2'
gemspec

group :development do
gem "aruba"
Expand Down
7 changes: 3 additions & 4 deletions hiera-eyaml-kms.gemspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'hiera/backend/eyaml/encryptors/kms'

Gem::Specification.new do |gem|
gem.name = "hiera-eyaml-kms"
gem.version = Hiera::Backend::Eyaml::Encryptors::Kms::VERSION
gem.version = "0.2"
gem.description = "AWS KMS encryptor for use with hiera-eyaml"
gem.summary = "Encryption plugin for hiera-eyaml backend for Hiera"
gem.author = "Allan Denot"
Expand All @@ -16,4 +13,6 @@ Gem::Specification.new do |gem|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]

gem.add_runtime_dependency 'aws-sdk-kms'
end
10 changes: 3 additions & 7 deletions lib/hiera/backend/eyaml/encryptors/kms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'hiera/backend/eyaml/encryptor'
require 'hiera/backend/eyaml/utils'
require 'hiera/backend/eyaml/options'
require 'aws-sdk'
require 'aws-sdk-kms'

class Hiera
module Backend
Expand All @@ -26,18 +26,15 @@ class Kms < Encryptor
VERSION = "0.2"
self.tag = "KMS"



def self.encrypt plaintext
aws_profile = self.option :aws_profile
credentials = Aws::SharedCredentials.new(profile_name: aws_profile)
aws_region = self.option :aws_region
key_id = self.option :key_id
raise StandardError, "key_id is not defined" unless key_id

@kms = ::Aws::KMS::Client.new(
profile: aws_profile,
region: aws_region,
credentials: credentials,
)

resp = @kms.encrypt({
Expand All @@ -50,12 +47,11 @@ def self.encrypt plaintext

def self.decrypt ciphertext
aws_profile = self.option :aws_profile
credentials = Aws::SharedCredentials.new(profile_name: aws_profile)
aws_region = self.option :aws_region

@kms = ::Aws::KMS::Client.new(
profile: aws_profile,
region: aws_region,
credentials: credentials,
)

resp = @kms.decrypt({
Expand Down