aws_ebs_volumes Resource
Use the aws_ebs_volumes
InSpec audit resource to test the properties of a collection of AWS EBS volumes.
EBS volumes are persistent block storage volumes for Amazon EC2 instances in the AWS Cloud.
For additional information, including details on parameters and properties, see the AWS documentation on EBS.
Install
This resource is available in the Chef InSpec AWS resource pack.
For information on configuring your AWS environment for Chef InSpec and creating an InSpec profile that uses the InSpec AWS resource pack, see the Chef InSpec documentation on the AWS cloud platform.
Syntax
Ensure you have exactly three volumes.
describe aws_ebs_volumes do
its('VOLUME_ID_COUNT') { should cmp 3 }
end
Parameters
This resource does not require any parameters.
Properties
attachments
- The EBS volume attachments returned.
availability_zones
- The list of availability zones in use by the EBS volumes.
create_times
- The creation times of the EBS volumes.
encrypted
- The list of true/false values indicating whether the EBS volumes are encrypted.
fast_restored
- The list of true/false values indicating whether the EBS volume is created with a snapshot enabled for fast snapshot restore.
iops
- The list of I/O per second for each EBS volume.
kms_key_ids
- The list of ARNs for EBS volume KMS keys.
multi_attach_enabled
- The list of boolean values indicating whether the EBS volume is multi-attach enabled.
outpost_arns
- The list of ARNs of outposts.
sizes
- The list of EBS volume sizes.
snapshot_ids
- The list of snapshots from which EBS volumes are created.
states
- The list of volume states returned.
tags
- The list of volume tags returned.
volume_ids
- The unique IDs of the EBS volumes returned.
volume_types
- The list of volume types returned.
entries
- Provides access to the raw results of the query, which can be treated as an array of hashes.
Examples
Ensure a specific volume exists.
describe aws_ebs_volumes do
its('VOLUME_IDs') { should include 'VOLUME-12345678' }
end
Request the EBS volumes IDs.
Test in-depth using aws_ebs_volume
to ensure all volumes are encrypted and have a sensible size.
aws_ebs_volumes.volume_ids.each do |volume_id|
describe aws_ebs_volume(volume_id) do
it { should be_encrypted }
its('size') { should be > 10 }
its('iops') { should cmp 100 }
end
end
Matchers
For a full list of available matchers, see our Universal Matchers page.This resource has the following special matchers.
exist
The control will pass if the describe returns at least one result.
Use should_not
to test the entity should not exist.
describe aws_ebs_volumes do
it { should exist }
end
describe aws_ebs_volumes do
it { should_not exist }
end
AWS Permissions
Your Principal will need the EC2:Client:DescribeVolumesResult
action with Effect
set to Allow
.
You can find detailed documentation at Actions, Resources, and Condition Keys for Amazon EC2, and Actions, Resources, and Condition Keys for Identity And Access Management.