Skip to main content

aws_ec2_volume_attachments Resource

[edit on GitHub]

Use the aws_ec2_volume_attachments InSpec audit resource to test properties of multiple AWS EC2 volume attachments.

The AWS::EC2::VolumeAttachment resource attaches an Amazon EBS volume to a running instance and exposes it to the instance with the specified device name.

For additional information, including details on parameters and properties, see the AWS documentation on AWS EC2 Volume Attachment.

Installation

This resource is available in the Chef InSpec AWS resource pack.

See the Chef InSpec documentation on cloud platforms for information on configuring your AWS environment for InSpec and creating an InSpec profile that uses the InSpec AWS resource pack.

Syntax

Ensure that volume attachment exists.

describe aws_ec2_volume_attachments do
  it { should exist }
end

Parameters

This resource does not require any parameters.

Properties

attach_times
The time stamp when the attachment initiated.

Field: attach_time

devices
The device name.

Field: device

instance_ids
The ID of the instance.

Field: instance_id

states
The attachment state of the volume.

Field: state

volume_ids
The ID of the volume.

Field: volume_id

delete_on_terminations
Indicates whether the EBS volume is deleted on instance termination.

Field: delete_on_termination

Examples

Ensure a device is available.

describe aws_ec2_volume_attachments do
  its('devices') { should include '/dev/sdf' }
end

Ensure that the state is available.

describe aws_ec2_volume_attachments do
    its('states') { should include 'available' }
end

Matchers

This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our Universal Matchers page.

The controls will pass if the describe method returns at least one result.

exist

Use should to test that the entity exists.

describe aws_ec2_volume_attachments do
  it { should exist }
end

Use should_not to test the entity does not exist.

describe aws_ec2_volume_attachments do
  it { should_not exist }
end

AWS Permissions

Your Principal will need the EC2:Client:DescribeVolumesResult action with Effect set to Allow.

Was this page helpful?

×









Search Results