aws_ec2_network_interface_attachments resource
Use the aws_ec2_network_interface_attachments InSpec audit resource to test properties of multiple AWS EC2 network interface attachments.
The AWS::EC2::NetworkInterfaceAttachment resource attaches an elastic network interface (ENI) to an Amazon EC2 instance. You can use this resource type to attach additional network interfaces to an instance without interruption.
For additional information, including details on parameters and properties, see the AWS documentation on AWS Lambda Function.
Syntax
Ensure that a network interface attachment exists.
describe aws_ec2_network_interface_attachments do
it { should exist }
end
Parameters
This resource does not require any parameters.
Properties
attach_times- The timestamp indicating when the attachment initiated.
Field:
attach_timeattachment_ids- The ID of the network interface attachment.
Field:
attachment_iddelete_on_terminations- Indicates whether the network interface is deleted when the instance is terminated.
Field:
delete_on_terminationdevice_indexes- The device index of the network interface attachment on the instance.
Field:
device_indexnetwork_card_indexes- The index of the network card.
Field:
network_card_indexinstance_ids- The ID of the instance.
Field:
instance_idinstance_owner_ids- The Amazon Web Services account ID of the owner of the instance.
Field:
instance_owner_idstatuses- The attachment state.
Field:
status
Examples
Ensure an attachment ID is available:
describe aws_ec2_network_interface_attachment(network_interface_id: 'NETWORK_INTERFACE_ID') do
its('attachment_ids') { should include 'ATTACHMENT_ID' }
end
Ensure that a network interface status is available:
describe aws_ec2_network_interface_attachment(network_interface_id: 'NETWORK_INTERFACE_ID') do
its('statuses') { should include '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_network_interface_attachments do
it { should exist }
end
Use should_not to test the entity does not exist.
describe aws_ec2_network_interface_attachments do
it { should_not exist }
end
AWS Permissions
Your AWS principal will need the EC2:Client:DescribeNetworkInterfacesResult action with Effect set to Allow.