GetNetworkInterfaces
Use this data source to get a list of elastic network interfaces according to the specified filters in an Alibaba Cloud account.
For information about elastic network interface and how to use it, see Elastic Network Interface
Argument Reference
The following arguments are supported:
ids- (Optional) A list of ENI IDs.name_regex- (Optional) A regex string to filter results by ENI name.vpc_id- (Optional) The VPC ID linked to ENIs.vswitch_id- (Optional) The VSwitch ID linked to ENIs.private_ip- (Optional) The primary private IP address of the ENI.security_group_id- (Optional) The security group ID linked to ENIs.name- (Optional) The name of the ENIs.type- (Optional) The type of ENIs, Only support for “Primary” or “Secondary”.instance_id- (Optional) The ECS instance ID that the ENI is attached to.tags- (Optional) A map of tags assigned to ENIs.output_file- (Optional) The name of output file that saves the filter results.resource_group_id- (Optional, ForceNew, Available in 1.57.0+) The Id of resource group which the network interface belongs.
Example Usage
using Pulumi;
using AliCloud = Pulumi.AliCloud;
class MyStack : Stack
{
public MyStack()
{
var config = new Config();
var name = config.Get("name") ?? "networkInterfacesName";
var vpc = new AliCloud.Vpc.Network("vpc", new AliCloud.Vpc.NetworkArgs
{
CidrBlock = "192.168.0.0/24",
});
var defaultZones = Output.Create(AliCloud.GetZones.InvokeAsync(new AliCloud.GetZonesArgs
{
AvailableResourceCreation = "VSwitch",
}));
var vswitch = new AliCloud.Vpc.Switch("vswitch", new AliCloud.Vpc.SwitchArgs
{
AvailabilityZone = defaultZones.Apply(defaultZones => defaultZones.Zones[0].Id),
CidrBlock = "192.168.0.0/24",
VpcId = vpc.Id,
});
var @group = new AliCloud.Ecs.SecurityGroup("group", new AliCloud.Ecs.SecurityGroupArgs
{
VpcId = vpc.Id,
});
var @interface = new AliCloud.Vpc.NetworkInterface("interface", new AliCloud.Vpc.NetworkInterfaceArgs
{
Description = "Basic test",
PrivateIp = "192.168.0.2",
SecurityGroups =
{
@group.Id,
},
Tags =
{
{ "TF-VER", "0.11.3" },
},
VswitchId = vswitch.Id,
});
var instance = new AliCloud.Ecs.Instance("instance", new AliCloud.Ecs.InstanceArgs
{
AvailabilityZone = defaultZones.Apply(defaultZones => defaultZones.Zones[0].Id),
ImageId = "centos_7_04_64_20G_alibase_201701015.vhd",
InstanceName = name,
InstanceType = "ecs.e3.xlarge",
InternetMaxBandwidthOut = 10,
SecurityGroups =
{
@group.Id,
},
SystemDiskCategory = "cloud_efficiency",
VswitchId = vswitch.Id,
});
var attachment = new AliCloud.Vpc.NetworkInterfaceAttachment("attachment", new AliCloud.Vpc.NetworkInterfaceAttachmentArgs
{
InstanceId = instance.Id,
NetworkInterfaceId = @interface.Id,
});
var defaultNetworkInterfaces = Output.Tuple(attachment.NetworkInterfaceId, instance.Id, @group.Id, vpc.Id, vswitch.Id).Apply(values =>
{
var networkInterfaceId = values.Item1;
var instanceId = values.Item2;
var groupId = values.Item3;
var vpcId = values.Item4;
var vswitchId = values.Item5;
return AliCloud.Ecs.GetNetworkInterfaces.InvokeAsync(new AliCloud.Ecs.GetNetworkInterfacesArgs
{
Ids =
{
networkInterfaceId,
},
InstanceId = instanceId,
NameRegex = name,
PrivateIp = "192.168.0.2",
SecurityGroupId = groupId,
Tags =
{
{ "TF-VER", "0.11.3" },
},
Type = "Secondary",
VpcId = vpcId,
VswitchId = vswitchId,
});
});
this.Eni0Name = defaultNetworkInterfaces.Apply(defaultNetworkInterfaces => defaultNetworkInterfaces.Interfaces[0].Name);
}
[Output("eni0Name")]
public Output<string> Eni0Name { get; set; }
}
Coming soon!
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "networkInterfacesName"
vpc = alicloud.vpc.Network("vpc", cidr_block="192.168.0.0/24")
default_zones = alicloud.get_zones(available_resource_creation="VSwitch")
vswitch = alicloud.vpc.Switch("vswitch",
availability_zone=default_zones.zones[0]["id"],
cidr_block="192.168.0.0/24",
vpc_id=vpc.id)
group = alicloud.ecs.SecurityGroup("group", vpc_id=vpc.id)
interface = alicloud.vpc.NetworkInterface("interface",
description="Basic test",
private_ip="192.168.0.2",
security_groups=[group.id],
tags={
"TF-VER": "0.11.3",
},
vswitch_id=vswitch.id)
instance = alicloud.ecs.Instance("instance",
availability_zone=default_zones.zones[0]["id"],
image_id="centos_7_04_64_20G_alibase_201701015.vhd",
instance_name=name,
instance_type="ecs.e3.xlarge",
internet_max_bandwidth_out=10,
security_groups=[group.id],
system_disk_category="cloud_efficiency",
vswitch_id=vswitch.id)
attachment = alicloud.vpc.NetworkInterfaceAttachment("attachment",
instance_id=instance.id,
network_interface_id=interface.id)
default_network_interfaces = pulumi.Output.all(attachment.network_interface_id, instance.id, group.id, vpc.id, vswitch.id).apply(lambda network_interface_id, instanceId, groupId, vpcId, vswitchId: alicloud.ecs.get_network_interfaces(ids=[network_interface_id],
instance_id=instance_id,
name_regex=name,
private_ip="192.168.0.2",
security_group_id=group_id,
tags={
"TF-VER": "0.11.3",
},
type="Secondary",
vpc_id=vpc_id,
vswitch_id=vswitch_id))
pulumi.export("eni0Name", default_network_interfaces.interfaces[0]["name"])import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "networkInterfacesName";
const vpc = new alicloud.vpc.Network("vpc", {
cidrBlock: "192.168.0.0/24",
});
const defaultZones = pulumi.output(alicloud.getZones({
availableResourceCreation: "VSwitch",
}, { async: true }));
const vswitch = new alicloud.vpc.Switch("vswitch", {
availabilityZone: defaultZones.zones[0].id,
cidrBlock: "192.168.0.0/24",
vpcId: vpc.id,
});
const group = new alicloud.ecs.SecurityGroup("group", {
vpcId: vpc.id,
});
const interfaceNetworkInterface = new alicloud.vpc.NetworkInterface("interface", {
description: "Basic test",
privateIp: "192.168.0.2",
securityGroups: [group.id],
tags: {
"TF-VER": "0.11.3",
},
vswitchId: vswitch.id,
});
const instance = new alicloud.ecs.Instance("instance", {
availabilityZone: defaultZones.zones[0].id,
imageId: "centos_7_04_64_20G_alibase_201701015.vhd",
instanceName: name,
instanceType: "ecs.e3.xlarge",
internetMaxBandwidthOut: 10,
securityGroups: [group.id],
systemDiskCategory: "cloud_efficiency",
vswitchId: vswitch.id,
});
const attachment = new alicloud.vpc.NetworkInterfaceAttachment("attachment", {
instanceId: instance.id,
networkInterfaceId: interfaceNetworkInterface.id,
});
const defaultNetworkInterfaces = pulumi.all([attachment.networkInterfaceId, instance.id, group.id, vpc.id, vswitch.id]).apply(([networkInterfaceId, instanceId, groupId, vpcId, vswitchId]) => alicloud.ecs.getNetworkInterfaces({
ids: [networkInterfaceId],
instanceId: instanceId,
nameRegex: name,
privateIp: "192.168.0.2",
securityGroupId: groupId,
tags: {
"TF-VER": "0.11.3",
},
type: "Secondary",
vpcId: vpcId,
vswitchId: vswitchId,
}, { async: true }));
export const eni0Name = defaultNetworkInterfaces.interfaces[0].name;Using GetNetworkInterfaces
function getNetworkInterfaces(args: GetNetworkInterfacesArgs, opts?: InvokeOptions): Promise<GetNetworkInterfacesResult>function get_network_interfaces(ids=None, instance_id=None, name_regex=None, output_file=None, private_ip=None, resource_group_id=None, security_group_id=None, tags=None, type=None, vpc_id=None, vswitch_id=None, opts=None)func GetNetworkInterfaces(ctx *Context, args *GetNetworkInterfacesArgs, opts ...InvokeOption) (*GetNetworkInterfacesResult, error)public static class GetNetworkInterfaces {
public static Task<GetNetworkInterfacesResult> InvokeAsync(GetNetworkInterfacesArgs args, InvokeOptions? opts = null)
}The following arguments are supported:
- Ids List<string>
- Instance
Id string ID of the instance that the ENI is attached to.
- Name
Regex string - Output
File string - Private
Ip string Primary private IP of the ENI.
- Resource
Group stringId The Id of resource group.
- Security
Group stringId - Dictionary<string, object>
A map of tags assigned to the ENI.
- Type string
- Vpc
Id string ID of the VPC that the ENI belongs to.
- Vswitch
Id string ID of the VSwitch that the ENI is linked to.
- Ids []string
- Instance
Id string ID of the instance that the ENI is attached to.
- Name
Regex string - Output
File string - Private
Ip string Primary private IP of the ENI.
- Resource
Group stringId The Id of resource group.
- Security
Group stringId - map[string]interface{}
A map of tags assigned to the ENI.
- Type string
- Vpc
Id string ID of the VPC that the ENI belongs to.
- Vswitch
Id string ID of the VSwitch that the ENI is linked to.
- ids string[]
- instance
Id string ID of the instance that the ENI is attached to.
- name
Regex string - output
File string - private
Ip string Primary private IP of the ENI.
- resource
Group stringId The Id of resource group.
- security
Group stringId - {[key: string]: any}
A map of tags assigned to the ENI.
- type string
- vpc
Id string ID of the VPC that the ENI belongs to.
- vswitch
Id string ID of the VSwitch that the ENI is linked to.
- ids List[str]
- instance_
id str ID of the instance that the ENI is attached to.
- name_
regex str - output_
file str - private_
ip str Primary private IP of the ENI.
- resource_
group_ strid The Id of resource group.
- security_
group_ strid - Dict[str, Any]
A map of tags assigned to the ENI.
- type str
- vpc_
id str ID of the VPC that the ENI belongs to.
- vswitch_
id str ID of the VSwitch that the ENI is linked to.
GetNetworkInterfaces Result
The following output properties are available:
- Id string
The provider-assigned unique ID for this managed resource.
- Ids List<string>
- Interfaces
List<Pulumi.
Ali Cloud. Ecs. Outputs. Get Network Interfaces Interface> A list of ENIs. Each element contains the following attributes:
- Names List<string>
- Instance
Id string ID of the instance that the ENI is attached to.
- Name
Regex string - Output
File string - Private
Ip string Primary private IP of the ENI.
- Resource
Group stringId The Id of resource group.
- Security
Group stringId - Dictionary<string, object>
A map of tags assigned to the ENI.
- Type string
- Vpc
Id string ID of the VPC that the ENI belongs to.
- Vswitch
Id string ID of the VSwitch that the ENI is linked to.
- Id string
The provider-assigned unique ID for this managed resource.
- Ids []string
- Interfaces
[]Get
Network Interfaces Interface A list of ENIs. Each element contains the following attributes:
- Names []string
- Instance
Id string ID of the instance that the ENI is attached to.
- Name
Regex string - Output
File string - Private
Ip string Primary private IP of the ENI.
- Resource
Group stringId The Id of resource group.
- Security
Group stringId - map[string]interface{}
A map of tags assigned to the ENI.
- Type string
- Vpc
Id string ID of the VPC that the ENI belongs to.
- Vswitch
Id string ID of the VSwitch that the ENI is linked to.
- id string
The provider-assigned unique ID for this managed resource.
- ids string[]
- interfaces
Get
Network Interfaces Interface[] A list of ENIs. Each element contains the following attributes:
- names string[]
- instance
Id string ID of the instance that the ENI is attached to.
- name
Regex string - output
File string - private
Ip string Primary private IP of the ENI.
- resource
Group stringId The Id of resource group.
- security
Group stringId - {[key: string]: any}
A map of tags assigned to the ENI.
- type string
- vpc
Id string ID of the VPC that the ENI belongs to.
- vswitch
Id string ID of the VSwitch that the ENI is linked to.
- id str
The provider-assigned unique ID for this managed resource.
- ids List[str]
- interfaces
List[Get
Network Interfaces Interface] A list of ENIs. Each element contains the following attributes:
- names List[str]
- instance_
id str ID of the instance that the ENI is attached to.
- name_
regex str - output_
file str - private_
ip str Primary private IP of the ENI.
- resource_
group_ strid The Id of resource group.
- security_
group_ strid - Dict[str, Any]
A map of tags assigned to the ENI.
- type str
- vpc_
id str ID of the VPC that the ENI belongs to.
- vswitch_
id str ID of the VSwitch that the ENI is linked to.
Supporting Types
GetNetworkInterfacesInterface
See the output API doc for this type.
See the output API doc for this type.
See the output API doc for this type.
- Creation
Time string Creation time of the ENI.
- Description string
Description of the ENI.
- Id string
ID of the ENI.
- Instance
Id string ID of the instance that the ENI is attached to.
- Mac string
MAC address of the ENI.
- Name string
Name of the ENI.
- Private
Ip string Primary private IP of the ENI.
- Private
Ips List<string> A list of secondary private IP address that is assigned to the ENI.
- Public
Ip string Public IP of the ENI.
- Resource
Group stringId The Id of resource group.
- Security
Groups List<string> A list of security group that the ENI belongs to.
- Status string
Current status of the ENI.
- Vpc
Id string ID of the VPC that the ENI belongs to.
- Vswitch
Id string ID of the VSwitch that the ENI is linked to.
- Zone
Id string ID of the availability zone that the ENI belongs to.
- Dictionary<string, object>
A map of tags assigned to the ENI.
- Creation
Time string Creation time of the ENI.
- Description string
Description of the ENI.
- Id string
ID of the ENI.
- Instance
Id string ID of the instance that the ENI is attached to.
- Mac string
MAC address of the ENI.
- Name string
Name of the ENI.
- Private
Ip string Primary private IP of the ENI.
- Private
Ips []string A list of secondary private IP address that is assigned to the ENI.
- Public
Ip string Public IP of the ENI.
- Resource
Group stringId The Id of resource group.
- Security
Groups []string A list of security group that the ENI belongs to.
- Status string
Current status of the ENI.
- Vpc
Id string ID of the VPC that the ENI belongs to.
- Vswitch
Id string ID of the VSwitch that the ENI is linked to.
- Zone
Id string ID of the availability zone that the ENI belongs to.
- map[string]interface{}
A map of tags assigned to the ENI.
- creation
Time string Creation time of the ENI.
- description string
Description of the ENI.
- id string
ID of the ENI.
- instance
Id string ID of the instance that the ENI is attached to.
- mac string
MAC address of the ENI.
- name string
Name of the ENI.
- private
Ip string Primary private IP of the ENI.
- private
Ips string[] A list of secondary private IP address that is assigned to the ENI.
- public
Ip string Public IP of the ENI.
- resource
Group stringId The Id of resource group.
- security
Groups string[] A list of security group that the ENI belongs to.
- status string
Current status of the ENI.
- vpc
Id string ID of the VPC that the ENI belongs to.
- vswitch
Id string ID of the VSwitch that the ENI is linked to.
- zone
Id string ID of the availability zone that the ENI belongs to.
- {[key: string]: any}
A map of tags assigned to the ENI.
- creation_
time str Creation time of the ENI.
- description str
Description of the ENI.
- id str
ID of the ENI.
- instance_
id str ID of the instance that the ENI is attached to.
- mac str
MAC address of the ENI.
- name str
Name of the ENI.
- private_
ip str Primary private IP of the ENI.
- private_
ips List[str] A list of secondary private IP address that is assigned to the ENI.
- public_
ip str Public IP of the ENI.
- resource_
group_ strid The Id of resource group.
- security_
groups List[str] A list of security group that the ENI belongs to.
- status str
Current status of the ENI.
- vpc_
id str ID of the VPC that the ENI belongs to.
- vswitch_
id str ID of the VSwitch that the ENI is linked to.
- zone_
id str ID of the availability zone that the ENI belongs to.
- Dict[str, Any]
A map of tags assigned to the ENI.
Package Details
- Repository
- https://github.com/pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloudTerraform Provider.