Sha256: d346a7c8d14291d45d44819f544cc4fa14abd96fc7f1c270464e35823ad4a782

Contents?: true

Size: 1.31 KB

Versions: 16

Compression:

Stored size: 1.31 KB

Contents

class AwsKmsKeys < Inspec.resource(1)
  name 'aws_kms_keys'
  desc 'Verifies settings for AWS KMS Keys in bulk'
  example '
    describe aws_kms_keys do
      it { should exist }
    end
  '
  supports platform: 'aws'

  include AwsPluralResourceMixin
  def validate_params(resource_params)
    unless resource_params.empty?
      raise ArgumentError, 'aws_kms_keys does not accept resource parameters.'
    end
    resource_params
  end

  # Underlying FilterTable implementation.
  filter = FilterTable.create
  filter.add_accessor(:entries)
        .add(:exists?) { |x| !x.entries.empty? }
        .add(:key_arns, field: :key_arn)
        .add(:key_ids, field: :key_id)
  filter.connect(self, :table)

  def to_s
    'KMS Keys'
  end

  def fetch_from_api
    backend = BackendFactory.create(inspec_runner)
    @table = []
    pagination_opts = { limit: 1000 }
    loop do
      api_result = backend.list_keys(pagination_opts)
      @table += api_result.keys.map(&:to_h)
      break unless api_result.truncated
      pagination_opts = { marker: api_result.next_marker }
    end
  end

  class Backend
    class AwsClientApi < AwsBackendBase
      BackendFactory.set_default_backend(self)
      self.aws_client_class = Aws::KMS::Client

      def list_keys(query = {})
        aws_service_client.list_keys(query)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
inspec-2.2.20 lib/resources/aws/aws_kms_keys.rb
inspec-2.2.16 lib/resources/aws/aws_kms_keys.rb
inspec-2.2.10 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.84 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.83 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.80 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.78 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.72 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.68 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.67 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.59 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.54 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.43 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.30 lib/resources/aws/aws_kms_keys.rb
inspec-2.1.0 lib/resources/aws/aws_kms_keys.rb
inspec-2.0.45 lib/resources/aws/aws_kms_keys.rb