github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/networkInterfaceAttachment.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package ec2
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Attach an Elastic network interface (ENI) resource with EC2 instance.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			_, err := ec2.NewNetworkInterfaceAttachment(ctx, "test", &ec2.NetworkInterfaceAttachmentArgs{
    33  //				InstanceId:         pulumi.Any(testAwsInstance.Id),
    34  //				NetworkInterfaceId: pulumi.Any(testAwsNetworkInterface.Id),
    35  //				DeviceIndex:        pulumi.Int(0),
    36  //			})
    37  //			if err != nil {
    38  //				return err
    39  //			}
    40  //			return nil
    41  //		})
    42  //	}
    43  //
    44  // ```
    45  // <!--End PulumiCodeChooser -->
    46  //
    47  // ## Import
    48  //
    49  // Using `pulumi import`, import Elastic network interface (ENI) Attachments using its Attachment ID. For example:
    50  //
    51  // ```sh
    52  // $ pulumi import aws:ec2/networkInterfaceAttachment:NetworkInterfaceAttachment secondary_nic eni-attach-0a33842b4ec347c4c
    53  // ```
    54  type NetworkInterfaceAttachment struct {
    55  	pulumi.CustomResourceState
    56  
    57  	// The ENI Attachment ID.
    58  	AttachmentId pulumi.StringOutput `pulumi:"attachmentId"`
    59  	// Network interface index (int).
    60  	DeviceIndex pulumi.IntOutput `pulumi:"deviceIndex"`
    61  	// Instance ID to attach.
    62  	InstanceId pulumi.StringOutput `pulumi:"instanceId"`
    63  	// ENI ID to attach.
    64  	NetworkInterfaceId pulumi.StringOutput `pulumi:"networkInterfaceId"`
    65  	// The status of the Network Interface Attachment.
    66  	Status pulumi.StringOutput `pulumi:"status"`
    67  }
    68  
    69  // NewNetworkInterfaceAttachment registers a new resource with the given unique name, arguments, and options.
    70  func NewNetworkInterfaceAttachment(ctx *pulumi.Context,
    71  	name string, args *NetworkInterfaceAttachmentArgs, opts ...pulumi.ResourceOption) (*NetworkInterfaceAttachment, error) {
    72  	if args == nil {
    73  		return nil, errors.New("missing one or more required arguments")
    74  	}
    75  
    76  	if args.DeviceIndex == nil {
    77  		return nil, errors.New("invalid value for required argument 'DeviceIndex'")
    78  	}
    79  	if args.InstanceId == nil {
    80  		return nil, errors.New("invalid value for required argument 'InstanceId'")
    81  	}
    82  	if args.NetworkInterfaceId == nil {
    83  		return nil, errors.New("invalid value for required argument 'NetworkInterfaceId'")
    84  	}
    85  	opts = internal.PkgResourceDefaultOpts(opts)
    86  	var resource NetworkInterfaceAttachment
    87  	err := ctx.RegisterResource("aws:ec2/networkInterfaceAttachment:NetworkInterfaceAttachment", name, args, &resource, opts...)
    88  	if err != nil {
    89  		return nil, err
    90  	}
    91  	return &resource, nil
    92  }
    93  
    94  // GetNetworkInterfaceAttachment gets an existing NetworkInterfaceAttachment resource's state with the given name, ID, and optional
    95  // state properties that are used to uniquely qualify the lookup (nil if not required).
    96  func GetNetworkInterfaceAttachment(ctx *pulumi.Context,
    97  	name string, id pulumi.IDInput, state *NetworkInterfaceAttachmentState, opts ...pulumi.ResourceOption) (*NetworkInterfaceAttachment, error) {
    98  	var resource NetworkInterfaceAttachment
    99  	err := ctx.ReadResource("aws:ec2/networkInterfaceAttachment:NetworkInterfaceAttachment", name, id, state, &resource, opts...)
   100  	if err != nil {
   101  		return nil, err
   102  	}
   103  	return &resource, nil
   104  }
   105  
   106  // Input properties used for looking up and filtering NetworkInterfaceAttachment resources.
   107  type networkInterfaceAttachmentState struct {
   108  	// The ENI Attachment ID.
   109  	AttachmentId *string `pulumi:"attachmentId"`
   110  	// Network interface index (int).
   111  	DeviceIndex *int `pulumi:"deviceIndex"`
   112  	// Instance ID to attach.
   113  	InstanceId *string `pulumi:"instanceId"`
   114  	// ENI ID to attach.
   115  	NetworkInterfaceId *string `pulumi:"networkInterfaceId"`
   116  	// The status of the Network Interface Attachment.
   117  	Status *string `pulumi:"status"`
   118  }
   119  
   120  type NetworkInterfaceAttachmentState struct {
   121  	// The ENI Attachment ID.
   122  	AttachmentId pulumi.StringPtrInput
   123  	// Network interface index (int).
   124  	DeviceIndex pulumi.IntPtrInput
   125  	// Instance ID to attach.
   126  	InstanceId pulumi.StringPtrInput
   127  	// ENI ID to attach.
   128  	NetworkInterfaceId pulumi.StringPtrInput
   129  	// The status of the Network Interface Attachment.
   130  	Status pulumi.StringPtrInput
   131  }
   132  
   133  func (NetworkInterfaceAttachmentState) ElementType() reflect.Type {
   134  	return reflect.TypeOf((*networkInterfaceAttachmentState)(nil)).Elem()
   135  }
   136  
   137  type networkInterfaceAttachmentArgs struct {
   138  	// Network interface index (int).
   139  	DeviceIndex int `pulumi:"deviceIndex"`
   140  	// Instance ID to attach.
   141  	InstanceId string `pulumi:"instanceId"`
   142  	// ENI ID to attach.
   143  	NetworkInterfaceId string `pulumi:"networkInterfaceId"`
   144  }
   145  
   146  // The set of arguments for constructing a NetworkInterfaceAttachment resource.
   147  type NetworkInterfaceAttachmentArgs struct {
   148  	// Network interface index (int).
   149  	DeviceIndex pulumi.IntInput
   150  	// Instance ID to attach.
   151  	InstanceId pulumi.StringInput
   152  	// ENI ID to attach.
   153  	NetworkInterfaceId pulumi.StringInput
   154  }
   155  
   156  func (NetworkInterfaceAttachmentArgs) ElementType() reflect.Type {
   157  	return reflect.TypeOf((*networkInterfaceAttachmentArgs)(nil)).Elem()
   158  }
   159  
   160  type NetworkInterfaceAttachmentInput interface {
   161  	pulumi.Input
   162  
   163  	ToNetworkInterfaceAttachmentOutput() NetworkInterfaceAttachmentOutput
   164  	ToNetworkInterfaceAttachmentOutputWithContext(ctx context.Context) NetworkInterfaceAttachmentOutput
   165  }
   166  
   167  func (*NetworkInterfaceAttachment) ElementType() reflect.Type {
   168  	return reflect.TypeOf((**NetworkInterfaceAttachment)(nil)).Elem()
   169  }
   170  
   171  func (i *NetworkInterfaceAttachment) ToNetworkInterfaceAttachmentOutput() NetworkInterfaceAttachmentOutput {
   172  	return i.ToNetworkInterfaceAttachmentOutputWithContext(context.Background())
   173  }
   174  
   175  func (i *NetworkInterfaceAttachment) ToNetworkInterfaceAttachmentOutputWithContext(ctx context.Context) NetworkInterfaceAttachmentOutput {
   176  	return pulumi.ToOutputWithContext(ctx, i).(NetworkInterfaceAttachmentOutput)
   177  }
   178  
   179  // NetworkInterfaceAttachmentArrayInput is an input type that accepts NetworkInterfaceAttachmentArray and NetworkInterfaceAttachmentArrayOutput values.
   180  // You can construct a concrete instance of `NetworkInterfaceAttachmentArrayInput` via:
   181  //
   182  //	NetworkInterfaceAttachmentArray{ NetworkInterfaceAttachmentArgs{...} }
   183  type NetworkInterfaceAttachmentArrayInput interface {
   184  	pulumi.Input
   185  
   186  	ToNetworkInterfaceAttachmentArrayOutput() NetworkInterfaceAttachmentArrayOutput
   187  	ToNetworkInterfaceAttachmentArrayOutputWithContext(context.Context) NetworkInterfaceAttachmentArrayOutput
   188  }
   189  
   190  type NetworkInterfaceAttachmentArray []NetworkInterfaceAttachmentInput
   191  
   192  func (NetworkInterfaceAttachmentArray) ElementType() reflect.Type {
   193  	return reflect.TypeOf((*[]*NetworkInterfaceAttachment)(nil)).Elem()
   194  }
   195  
   196  func (i NetworkInterfaceAttachmentArray) ToNetworkInterfaceAttachmentArrayOutput() NetworkInterfaceAttachmentArrayOutput {
   197  	return i.ToNetworkInterfaceAttachmentArrayOutputWithContext(context.Background())
   198  }
   199  
   200  func (i NetworkInterfaceAttachmentArray) ToNetworkInterfaceAttachmentArrayOutputWithContext(ctx context.Context) NetworkInterfaceAttachmentArrayOutput {
   201  	return pulumi.ToOutputWithContext(ctx, i).(NetworkInterfaceAttachmentArrayOutput)
   202  }
   203  
   204  // NetworkInterfaceAttachmentMapInput is an input type that accepts NetworkInterfaceAttachmentMap and NetworkInterfaceAttachmentMapOutput values.
   205  // You can construct a concrete instance of `NetworkInterfaceAttachmentMapInput` via:
   206  //
   207  //	NetworkInterfaceAttachmentMap{ "key": NetworkInterfaceAttachmentArgs{...} }
   208  type NetworkInterfaceAttachmentMapInput interface {
   209  	pulumi.Input
   210  
   211  	ToNetworkInterfaceAttachmentMapOutput() NetworkInterfaceAttachmentMapOutput
   212  	ToNetworkInterfaceAttachmentMapOutputWithContext(context.Context) NetworkInterfaceAttachmentMapOutput
   213  }
   214  
   215  type NetworkInterfaceAttachmentMap map[string]NetworkInterfaceAttachmentInput
   216  
   217  func (NetworkInterfaceAttachmentMap) ElementType() reflect.Type {
   218  	return reflect.TypeOf((*map[string]*NetworkInterfaceAttachment)(nil)).Elem()
   219  }
   220  
   221  func (i NetworkInterfaceAttachmentMap) ToNetworkInterfaceAttachmentMapOutput() NetworkInterfaceAttachmentMapOutput {
   222  	return i.ToNetworkInterfaceAttachmentMapOutputWithContext(context.Background())
   223  }
   224  
   225  func (i NetworkInterfaceAttachmentMap) ToNetworkInterfaceAttachmentMapOutputWithContext(ctx context.Context) NetworkInterfaceAttachmentMapOutput {
   226  	return pulumi.ToOutputWithContext(ctx, i).(NetworkInterfaceAttachmentMapOutput)
   227  }
   228  
   229  type NetworkInterfaceAttachmentOutput struct{ *pulumi.OutputState }
   230  
   231  func (NetworkInterfaceAttachmentOutput) ElementType() reflect.Type {
   232  	return reflect.TypeOf((**NetworkInterfaceAttachment)(nil)).Elem()
   233  }
   234  
   235  func (o NetworkInterfaceAttachmentOutput) ToNetworkInterfaceAttachmentOutput() NetworkInterfaceAttachmentOutput {
   236  	return o
   237  }
   238  
   239  func (o NetworkInterfaceAttachmentOutput) ToNetworkInterfaceAttachmentOutputWithContext(ctx context.Context) NetworkInterfaceAttachmentOutput {
   240  	return o
   241  }
   242  
   243  // The ENI Attachment ID.
   244  func (o NetworkInterfaceAttachmentOutput) AttachmentId() pulumi.StringOutput {
   245  	return o.ApplyT(func(v *NetworkInterfaceAttachment) pulumi.StringOutput { return v.AttachmentId }).(pulumi.StringOutput)
   246  }
   247  
   248  // Network interface index (int).
   249  func (o NetworkInterfaceAttachmentOutput) DeviceIndex() pulumi.IntOutput {
   250  	return o.ApplyT(func(v *NetworkInterfaceAttachment) pulumi.IntOutput { return v.DeviceIndex }).(pulumi.IntOutput)
   251  }
   252  
   253  // Instance ID to attach.
   254  func (o NetworkInterfaceAttachmentOutput) InstanceId() pulumi.StringOutput {
   255  	return o.ApplyT(func(v *NetworkInterfaceAttachment) pulumi.StringOutput { return v.InstanceId }).(pulumi.StringOutput)
   256  }
   257  
   258  // ENI ID to attach.
   259  func (o NetworkInterfaceAttachmentOutput) NetworkInterfaceId() pulumi.StringOutput {
   260  	return o.ApplyT(func(v *NetworkInterfaceAttachment) pulumi.StringOutput { return v.NetworkInterfaceId }).(pulumi.StringOutput)
   261  }
   262  
   263  // The status of the Network Interface Attachment.
   264  func (o NetworkInterfaceAttachmentOutput) Status() pulumi.StringOutput {
   265  	return o.ApplyT(func(v *NetworkInterfaceAttachment) pulumi.StringOutput { return v.Status }).(pulumi.StringOutput)
   266  }
   267  
   268  type NetworkInterfaceAttachmentArrayOutput struct{ *pulumi.OutputState }
   269  
   270  func (NetworkInterfaceAttachmentArrayOutput) ElementType() reflect.Type {
   271  	return reflect.TypeOf((*[]*NetworkInterfaceAttachment)(nil)).Elem()
   272  }
   273  
   274  func (o NetworkInterfaceAttachmentArrayOutput) ToNetworkInterfaceAttachmentArrayOutput() NetworkInterfaceAttachmentArrayOutput {
   275  	return o
   276  }
   277  
   278  func (o NetworkInterfaceAttachmentArrayOutput) ToNetworkInterfaceAttachmentArrayOutputWithContext(ctx context.Context) NetworkInterfaceAttachmentArrayOutput {
   279  	return o
   280  }
   281  
   282  func (o NetworkInterfaceAttachmentArrayOutput) Index(i pulumi.IntInput) NetworkInterfaceAttachmentOutput {
   283  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *NetworkInterfaceAttachment {
   284  		return vs[0].([]*NetworkInterfaceAttachment)[vs[1].(int)]
   285  	}).(NetworkInterfaceAttachmentOutput)
   286  }
   287  
   288  type NetworkInterfaceAttachmentMapOutput struct{ *pulumi.OutputState }
   289  
   290  func (NetworkInterfaceAttachmentMapOutput) ElementType() reflect.Type {
   291  	return reflect.TypeOf((*map[string]*NetworkInterfaceAttachment)(nil)).Elem()
   292  }
   293  
   294  func (o NetworkInterfaceAttachmentMapOutput) ToNetworkInterfaceAttachmentMapOutput() NetworkInterfaceAttachmentMapOutput {
   295  	return o
   296  }
   297  
   298  func (o NetworkInterfaceAttachmentMapOutput) ToNetworkInterfaceAttachmentMapOutputWithContext(ctx context.Context) NetworkInterfaceAttachmentMapOutput {
   299  	return o
   300  }
   301  
   302  func (o NetworkInterfaceAttachmentMapOutput) MapIndex(k pulumi.StringInput) NetworkInterfaceAttachmentOutput {
   303  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *NetworkInterfaceAttachment {
   304  		return vs[0].(map[string]*NetworkInterfaceAttachment)[vs[1].(string)]
   305  	}).(NetworkInterfaceAttachmentOutput)
   306  }
   307  
   308  func init() {
   309  	pulumi.RegisterInputType(reflect.TypeOf((*NetworkInterfaceAttachmentInput)(nil)).Elem(), &NetworkInterfaceAttachment{})
   310  	pulumi.RegisterInputType(reflect.TypeOf((*NetworkInterfaceAttachmentArrayInput)(nil)).Elem(), NetworkInterfaceAttachmentArray{})
   311  	pulumi.RegisterInputType(reflect.TypeOf((*NetworkInterfaceAttachmentMapInput)(nil)).Elem(), NetworkInterfaceAttachmentMap{})
   312  	pulumi.RegisterOutputType(NetworkInterfaceAttachmentOutput{})
   313  	pulumi.RegisterOutputType(NetworkInterfaceAttachmentArrayOutput{})
   314  	pulumi.RegisterOutputType(NetworkInterfaceAttachmentMapOutput{})
   315  }