2018-02-01 15:21:54 +00:00
---
title: About the aws_kms_keys Resource
2018-02-14 01:42:39 +00:00
platform: aws
2018-02-01 15:21:54 +00:00
---
2018-02-15 02:23:29 +00:00
# aws\_kms\_keys
2018-02-01 15:21:54 +00:00
2019-04-26 18:24:29 +00:00
Use the `aws_kms_keys` Chef InSpec audit resource to test properties of some or all AWS KMS Keys.
2018-02-01 15:21:54 +00:00
2018-05-10 18:57:53 +00:00
AWS Key Management Service (KMS) is a managed service that makes creating and controlling your encryption keys for your data easier. KMS uses Hardware Security Modules (HSMs) to protect the security of your keys.
2018-02-14 01:42:39 +00:00
AWS Key Management Service is integrated with several other AWS services to help you protect the data you store with these services.
2018-02-01 15:21:54 +00:00
Each AWS KMS Key is uniquely identified by its key-id or key-arn.
<br>
2018-08-09 12:34:49 +00:00
## Availability
### Installation
2019-04-26 18:24:29 +00:00
This resource is distributed along with Chef InSpec itself. You can use it automatically.
2018-08-09 12:34:49 +00:00
### Version
This resource first became available in v2.0.16 of InSpec.
2018-02-01 15:21:54 +00:00
## Syntax
An `aws_kms_keys` resource block uses an optional filter to select a group of KMS Keys and then tests that group.
# Verify the number of KMS keys in the AWS account
describe aws_kms_keys do
its('entries.count') { should cmp 10 }
end
<br>
## Examples
2019-04-26 18:24:29 +00:00
The following examples show how to use this Chef InSpec audit resource.
2018-02-01 15:21:54 +00:00
As this is the initial release of `aws_kms_keys`, its limited functionality precludes examples.
<br>
2018-02-14 01:42:39 +00:00
## Properties
2018-02-01 15:21:54 +00:00
2018-02-14 01:42:39 +00:00
* `entries`, `key_arns`, `key_ids`
2018-02-01 15:21:54 +00:00
2018-02-14 01:42:39 +00:00
<br>
2018-02-01 15:21:54 +00:00
2018-02-14 01:42:39 +00:00
## Property Examples
2018-02-01 15:21:54 +00:00
2018-02-14 01:42:39 +00:00
### entries
Provides access to the raw results of a query. This can be useful for checking counts and other advanced operations.
# Allow at most 100 KMS Keys on the account
describe aws_kms_keys do
its('entries.count') { should be <= 100}
end
2018-02-01 15:21:54 +00:00
2018-02-15 02:23:29 +00:00
### key\_arns
2018-02-01 15:21:54 +00:00
Provides a list of key arns for all KMS Keys in the AWS account.
describe aws_kms_keys do
its('key_arns') { should include('arn:aws:kms:us-east-1::key/key-id') }
end
2018-02-15 02:23:29 +00:00
### key\_ids
2018-02-01 15:21:54 +00:00
Provides a list of key ids for all KMS Keys in the AWS account.
describe aws_kms_keys do
its('key_ids') { should include('fd7e608b-f435-4186-b8b5-111111111111') }
end
2018-02-14 01:42:39 +00:00
<br>
2018-02-01 15:21:54 +00:00
2018-02-14 01:42:39 +00:00
## Matchers
2019-04-26 18:24:29 +00:00
This Chef InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
2018-02-14 01:42:39 +00:00
### exists
The control will pass if the filter returns at least one result. Use `should_not` if you expect zero matches.
# Verify that at least one KMS Key exists.
describe aws_kms_keys
it { should exist }
2018-05-10 18:57:53 +00:00
end
## AWS Permissions
Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `kms:ListKeys` action with Effect set to Allow.
2018-02-01 15:21:54 +00:00
2018-05-10 18:57:53 +00:00
You can find detailed documentation at [Actions, Resources, and Condition Keys for AWS Key Management Service](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awskeymanagementservice.html).