Show / Hide Table of Contents

Class NetworkInterfaceAttachment

Provides an Alicloud ECS Elastic Network Interface Attachment as a resource to attach ENI to or detach ENI from ECS Instances.

For information about Elastic Network Interface and how to use it, see Elastic Network Interface.

Example Usage

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
public MyStack()
{
    var config = new Config();
    var name = config.Get("name") ?? "networkInterfaceAttachment";
    var number = config.Get("number") ?? "2";
    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 instanceType = defaultZones.Apply(defaultZones => Output.Create(AliCloud.Ecs.GetInstanceTypes.InvokeAsync(new AliCloud.Ecs.GetInstanceTypesArgs
    {
        AvailabilityZone = defaultZones.Zones[0].Id,
        EniAmount = 2,
    })));
    var defaultImages = Output.Create(AliCloud.Ecs.GetImages.InvokeAsync(new AliCloud.Ecs.GetImagesArgs
    {
        MostRecent = true,
        NameRegex = "^ubuntu_18.*64",
        Owners = "system",
    }));
    var instance = new List<AliCloud.Ecs.Instance>();
    for (var rangeIndex = 0; rangeIndex < number; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        instance.Add(new AliCloud.Ecs.Instance($"instance-{range.Value}", new AliCloud.Ecs.InstanceArgs
        {
            AvailabilityZone = defaultZones.Apply(defaultZones => defaultZones.Zones[0].Id),
            ImageId = defaultImages.Apply(defaultImages => defaultImages.Images[0].Id),
            InstanceName = name,
            InstanceType = instanceType.Apply(instanceType => instanceType.InstanceTypes[0].Id),
            InternetMaxBandwidthOut = 10,
            SecurityGroups = 
            {
                @group.Id,
            },
            SystemDiskCategory = "cloud_efficiency",
            VswitchId = vswitch.Id,
        }));
    }
    var @interface = new List<AliCloud.Vpc.NetworkInterface>();
    for (var rangeIndex = 0; rangeIndex < number; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        @interface.Add(new AliCloud.Vpc.NetworkInterface($"interface-{range.Value}", new AliCloud.Vpc.NetworkInterfaceArgs
        {
            SecurityGroups = 
            {
                @group.Id,
            },
            VswitchId = vswitch.Id,
        }));
    }
    var attachment = new List<AliCloud.Vpc.NetworkInterfaceAttachment>();
    for (var rangeIndex = 0; rangeIndex < number; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        attachment.Add(new AliCloud.Vpc.NetworkInterfaceAttachment($"attachment-{range.Value}", new AliCloud.Vpc.NetworkInterfaceAttachmentArgs
        {
            InstanceId = instance.Select(__item => __item.Id).ToList()[range.Index],
            NetworkInterfaceId = @interface.Select(__item => __item.Id).ToList()[range.Index],
        }));
    }
}

}
Inheritance
System.Object
Resource
CustomResource
NetworkInterfaceAttachment
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.AliCloud.Vpc
Assembly: Pulumi.AliCloud.dll
Syntax
public class NetworkInterfaceAttachment : CustomResource

Constructors

View Source

NetworkInterfaceAttachment(String, NetworkInterfaceAttachmentArgs, CustomResourceOptions)

Create a NetworkInterfaceAttachment resource with the given unique name, arguments, and options.

Declaration
public NetworkInterfaceAttachment(string name, NetworkInterfaceAttachmentArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

NetworkInterfaceAttachmentArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

InstanceId

The instance ID to attach.

Declaration
public Output<string> InstanceId { get; }
Property Value
Type Description
Output<System.String>
View Source

NetworkInterfaceId

The ENI ID to attach.

Declaration
public Output<string> NetworkInterfaceId { get; }
Property Value
Type Description
Output<System.String>

Methods

View Source

Get(String, Input<String>, NetworkInterfaceAttachmentState, CustomResourceOptions)

Get an existing NetworkInterfaceAttachment resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static NetworkInterfaceAttachment Get(string name, Input<string> id, NetworkInterfaceAttachmentState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

NetworkInterfaceAttachmentState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
NetworkInterfaceAttachment
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.