Sha256: c0318dd7fc3118ee52ecc95589865f41dd41d65192f729a18975b80fd95264df

Contents?: true

Size: 1020 Bytes

Versions: 63

Compression:

Stored size: 1020 Bytes

Contents

module Awspec::Helper
  module Finder
    module Kms
      def find_kms_key(key_id)
        kms_client.describe_key(key_id: key_id).key_metadata
      rescue
        nil
      end

      def find_kms_key_by_alias(key_alias_name)
        alias_name = key_alias_name.start_with?('alias/') ? key_alias_name : "alias/#{key_alias_name}"
        found = nil
        next_marker = nil

        loop do
          res = kms_client.list_aliases(marker: next_marker, limit: 100)
          found = res.aliases.find { |key_alias| key_alias.alias_name == alias_name }
          (found.nil? && next_marker = res.next_marker) || break
        end

        find_kms_key(found.target_key_id) if found
      end

      def select_all_kms_aliases
        all_aliases = []
        next_marker = nil

        loop do
          res = kms_client.list_aliases(marker: next_marker, limit: 100)
          all_aliases.concat(res.aliases)
          next_marker = res.next_marker || break
        end

        all_aliases
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 3 rubygems

Version Path
cthiesfork-awspec-1.2.2 lib/awspec/helper/finder/kms.rb
cthiesfork-awspec-1.2.1 lib/awspec/helper/finder/kms.rb
awspec-1.18.5 lib/awspec/helper/finder/kms.rb
cthiesfork-awspec-1.2.0 lib/awspec/helper/finder/kms.rb
cthiesfork-awspec-1.1.0 lib/awspec/helper/finder/kms.rb
cthiesfork-awspec-1.0.0 lib/awspec/helper/finder/kms.rb
awspec-1.18.4 lib/awspec/helper/finder/kms.rb
awspec-1.18.3 lib/awspec/helper/finder/kms.rb
awspec-1.18.2 lib/awspec/helper/finder/kms.rb
awspec-1.18.1 lib/awspec/helper/finder/kms.rb
awspec-1.18.0 lib/awspec/helper/finder/kms.rb
awspec-1.17.4 lib/awspec/helper/finder/kms.rb
awspec-1.17.3 lib/awspec/helper/finder/kms.rb
awspec-1.17.2 lib/awspec/helper/finder/kms.rb
awspec-1.17.1 lib/awspec/helper/finder/kms.rb
awspec-1.17.0 lib/awspec/helper/finder/kms.rb
awspec-1.16.1 lib/awspec/helper/finder/kms.rb
awspec-1.16.0 lib/awspec/helper/finder/kms.rb
awspec-1.15.3 lib/awspec/helper/finder/kms.rb
awspec-1.15.2 lib/awspec/helper/finder/kms.rb