Sha256: dac31fd0252e64a969bd0ea5ed74f991e3a304b1b5808fd121d93c96c047c42a
Contents?: true
Size: 965 Bytes
Versions: 44
Compression:
Stored size: 965 Bytes
Contents
module Awspec::Generator module Spec class Kms include Awspec::Helper::Finder def generate_all aliases = select_all_kms_aliases.select { |kms_alias| customer_managed_key?(kms_alias) } raise 'Not Found alias' if aliases.empty? ERB.new(keys_spec_template, nil, '-').result(binding).chomp end def keys_spec_template template = <<-'EOF' <% aliases.each do |kms_alias| %> describe kms('<%= kms_alias.alias_name.split('/').last %>') do it { should exist } <% if find_kms_key(kms_alias.target_key_id).enabled -%> it { should be_enabled } <% end -%> end <% end %> EOF template end private def customer_managed_key?(kms_alias) # An aliase that has no target key id field is predefined by AWS. # see: https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/KMS/Client.html#list_aliases-instance_method !kms_alias.target_key_id.nil? end end end end
Version data entries
44 entries across 44 versions & 3 rubygems