Skip to main content

aws_ec2_volume_attachment Resource

Use the aws_ec2_volume_attachment InSpec audit resource to test properties of a single specific AWS EC2 volume attachment.

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.

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 that volume attachment exists.

describe aws_ec2_volume_attachment(volume_id: 'VOLUME_ID') do
  it { should exist }
end

Parameters

volume_id (required)

The volume ID.

Properties

attach_time
The time stamp when the attachment initiated.
device
The device name.
instance_id
The ID of the instance.
state
The attachment state of the volume.
volume_id
The ID of the volume.
delete_on_termination
Indicates whether the EBS volume is deleted on instance termination.

Examples

Ensure a device is available.

describe aws_ec2_volume_attachment(volume_id: 'VOLUME_ID') do
  its('device') { should eq '/dev/sdf' }
end

Ensure that the state is available.

describe aws_ec2_volume_attachment(volume_id: 'VOLUME_ID') do
    its('state') { should eq 'available' }
end

Matchers

For a full list of available matchers, see 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_attachment(volume_id: 'VOLUME_ID') do
  it { should exist }
end

Use should_not to test the entity does not exist.

describe aws_ec2_volume_attachment(volume_id: 'dummy') do
  it { should_not exist }
end

be_available

Use should to check if the entity is available.

describe aws_ec2_volume_attachment(volume_id: 'VOLUME_ID') do
  it { should be_available }
end

AWS Permissions

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

Edit this page on GitHub

Thank you for your feedback!

×











Search Results