Table: aws_ec2_network_interface - Query AWS EC2 Network Interfaces using SQL
An AWS EC2 Network Interface is a virtual network interface that you can attach to an instance in a VPC. Network interfaces are the point of networking for any instance that is attached to a Virtual Private Cloud (VPC). They can include a primary private IPv4 address, one or more secondary private IPv4 addresses, one Elastic IP address per private IPv4 address, one public IPv4 address, one or more IPv6 addresses, a MAC address, one or more security groups, a source/destination check flag, and a description.
Table Usage Guide
The aws_ec2_network_interface
table in Steampipe provides you with information about Network Interfaces within AWS Elastic Compute Cloud (EC2). This table allows you, as a DevOps engineer, to query network interface-specific details, including the attached instances, associated security groups, subnet information, and more. You can utilize this table to gather insights on network interfaces, such as their status, type, private and public IP addresses, and the associated subnet and VPC details. The schema outlines for you the various attributes of the EC2 network interface, including the interface ID, description, owner ID, availability zone, and associated tags.
Examples
Basic IP address info
Determine the areas in which your AWS EC2 network interfaces are operating by exploring the type of interface, its corresponding private and public IP addresses, and its MAC address. This can be particularly useful for managing network connectivity and troubleshooting network issues within your AWS environment.
select network_interface_id, interface_type, description, private_ip_address, association_public_ip, mac_addressfrom aws_ec2_network_interface;
select network_interface_id, interface_type, description, private_ip_address, association_public_ip, mac_addressfrom aws_ec2_network_interface;
Find all ENIs with private IPs that are in a given subnet (10.66.0.0/16)
Discover the segments that have private IPs within a specific subnet. This is useful for identifying network interfaces within a particular subnet, which can aid in network management and security assessment.
select network_interface_id, interface_type, description, private_ip_address, association_public_ip, mac_addressfrom aws_ec2_network_interfacewhere private_ip_address :: cidr << = '10.66.0.0/16';
Error: SQLite does not support CIDR operations.
Count of ENIs by interface type
Discover the segments that have the most network interfaces in your AWS EC2 environment, helping you understand your network configuration and potentially optimize resource allocation.
select interface_type, count(interface_type) as countfrom aws_ec2_network_interfacegroup by interface_typeorder by count desc;
select interface_type, count(interface_type) as countfrom aws_ec2_network_interfacegroup by interface_typeorder by count desc;
Security groups attached to each ENI
Determine the areas in which certain security groups are attached to each network interface within your Amazon EC2 instances. This can help in managing security and access controls effectively.
select network_interface_id as eni, sg ->> 'GroupId' as "security group id", sg ->> 'GroupName' as "security group name"from aws_ec2_network_interface cross join jsonb_array_elements(groups) as sgorder by eni;
select network_interface_id as eni, json_extract(sg, '$.GroupId') as "security group id", json_extract(sg, '$.GroupName') as "security group name"from ( select network_interface_id, json_each.value as sg from aws_ec2_network_interface, json_each(groups) )order by eni;
Get network details for each ENI
Discover the segments that are common between your network interfaces and virtual private clouds (VPCs) to better understand your network structure. This can assist in identifying areas for potential consolidation or optimization.
select e.network_interface_id, v.vpc_id, v.is_default, v.cidr_block, v.state, v.account_id, v.regionfrom aws_ec2_network_interface e, aws_vpc vwhere e.vpc_id = v.vpc_id;
select e.network_interface_id, v.vpc_id, v.is_default, v.cidr_block, v.state, v.account_id, v.regionfrom aws_ec2_network_interface e join aws_vpc v on e.vpc_id = v.vpc_id;
Schema for aws_ec2_network_interface
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | =, !=, ~~, ~~*, !~~, !~~* | The AWS Account ID in which the resource is located. |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
association_allocation_id | text | = | Allocation id for the association. Association can be an Elastic IP address (IPv4 only), or a Carrier IP address. |
association_carrier_ip | inet | The carrier IP address associated with the network interface. | |
association_customer_owned_ip | inet | The customer-owned IP address associated with the network interface. | |
association_id | text | = | The association ID. |
association_ip_owner_id | text | = | The ID of the Elastic IP address owner. |
association_public_dns_name | text | = | The public DNS name of the association. |
association_public_ip | inet | = | The address of the Elastic IP address bound to the network interface. |
attached_instance_id | text | = | The ID of the attached instance. |
attached_instance_owner_id | text | = | The AWS account ID of the owner of the attached instance. |
attachment_id | text | = | The ID of the network interface attachment. |
attachment_status | text | = | The attachment state. |
attachment_time | timestamp with time zone | = | The timestamp indicating when the attachment initiated. |
availability_zone | text | = | The Availability Zone. |
connection_tracking_configuration | jsonb | A security group connection tracking configuration that enables you to set the timeout for connection tracking on an Elastic network interface. | |
delete_on_instance_termination | boolean | =, != | Indicates whether the network interface is deleted when the instance is terminated. |
deny_all_igw_traffic | boolean | Indicates whether a network interface with an IPv6 address is unreachable from the public internet. | |
description | text | = | A description. |
device_index | bigint | The device index of the network interface attachment on the instance. | |
groups | jsonb | Any security groups for the network interface. | |
interface_type | text | The type of network interface. | |
ipv4_prefixes | jsonb | The IPv4 prefixes associated with the network interface. | |
ipv6_address | text | The IPv6 globally unique address associated with the network interface. | |
ipv6_addresses | jsonb | The IPv6 addresses associated with the network interface. | |
ipv6_native | boolean | Indicates whether this is an IPv6 only network interface. | |
ipv6_prefixes | jsonb | The IPv6 prefixes that are assigned to the network interface. | |
mac_address | text | = | The MAC address of the interface. |
network_interface_id | text | = | The ID of the network interface. |
outpost_arn | text | The Amazon Resource Name (ARN) of the Outpost, if applicable. | |
owner_id | text | = | The AWS account ID of the owner of the network interface. |
partition | text | The AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov). | |
private_dns_name | text | = | The private DNS name |
private_ip_address | inet | = | The IPv4 address of the network interface within the subnet. |
private_ip_addresses | jsonb | The IPv4 address of the network interface within the subnet. | |
region | text | The AWS Region in which the resource is located. | |
requester_id | text | = | The ID of the entity that launched the instance on your behalf (for example, AWS Management Console or Auto Scaling). |
requester_managed | boolean | =, != | Indicates whether the network interface is being managed by AWS. |
source_dest_check | boolean | =, != | Indicates whether traffic to or from the instance is validated. |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
status | text | = | The status of the network interface. |
subnet_id | text | The ID of the subnet. | |
tags | jsonb | A map of tags for the resource. | |
tags_src | jsonb | A list of tags that are attached to the network interface. | |
title | text | Title of the resource. | |
vpc_id | text | The ID of the VPC. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- aws
You can pass the configuration to the command with the --config
argument:
steampipe_export_aws --config '<your_config>' aws_ec2_network_interface