Class: Aws::EC2::NetworkInterface

Inherits:
Object
  • Object
show all
Extended by:
Deprecations
Defined in:
sig/network_interface.rbs,
lib/aws-sdk-ec2/network_interface.rb

Overview

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Associations collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, options = {}) ⇒ NetworkInterface #initialize(options = {}) ⇒ NetworkInterface

Returns a new instance of NetworkInterface.

Overloads:

  • #initialize(id, options = {}) ⇒ NetworkInterface

    Parameters:

    • id (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ NetworkInterface

    Options Hash (options):

    • :id (required, String)
    • :client (Client)


13
14
15
# File 'sig/network_interface.rbs', line 13

def initialize: (String id, Hash[Symbol, untyped] options) -> void
| (id: String, ?client: Client) -> void
| (Hash[Symbol, untyped] args) -> void

Instance Method Details

#assign_private_ip_addresses(options = {}) ⇒ Types::AssignPrivateIpAddressesResult

Examples:

Request syntax with placeholder values


network_interface.assign_private_ip_addresses({
  ipv_4_prefixes: ["String"],
  ipv_4_prefix_count: 1,
  private_ip_addresses: ["String"],
  secondary_private_ip_address_count: 1,
  allow_reassignment: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :ipv_4_prefixes (Array<String>)

    One or more IPv4 prefixes assigned to the network interface. You can't use this option if you use the Ipv4PrefixCount option.

  • :ipv_4_prefix_count (Integer)

    The number of IPv4 prefixes that Amazon Web Services automatically assigns to the network interface. You can't use this option if you use the Ipv4 Prefixes option.

  • :private_ip_addresses (Array<String>)

    The IP addresses to be assigned as a secondary private IP address to the network interface. You can't specify this parameter when also specifying a number of secondary IP addresses.

    If you don't specify an IP address, Amazon EC2 automatically selects an IP address within the subnet range.

  • :secondary_private_ip_address_count (Integer)

    The number of secondary IP addresses to assign to the network interface. You can't specify this parameter when also specifying private IP addresses.

  • :allow_reassignment (Boolean)

    Indicates whether to allow an IP address that is already assigned to another network interface or instance to be reassigned to the specified network interface.

Returns:



125
# File 'sig/network_interface.rbs', line 125

def assign_private_ip_addresses: (

#associated_subnetsArray<String>

The subnets associated with this network interface.

Returns:

  • (Array<String>)


106
# File 'sig/network_interface.rbs', line 106

def associated_subnets: () -> ::Array[::String]

#associationNetworkInterfaceAssociation?

Returns:



240
# File 'sig/network_interface.rbs', line 240

def association: () -> NetworkInterfaceAssociation?

#attach(options = {}) ⇒ Types::AttachNetworkInterfaceResult

Examples:

Request syntax with placeholder values


network_interface.attach({
  network_card_index: 1,
  ena_srd_specification: {
    ena_srd_enabled: false,
    ena_srd_udp_specification: {
      ena_srd_udp_enabled: false,
    },
  },
  ena_queue_count: 1,
  dry_run: false,
  instance_id: "InstanceId", # required
  device_index: 1, # required
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :network_card_index (Integer)

    The index of the network card. Some instance types support multiple network cards. The primary network interface must be assigned to network card index 0. The default is network card index 0.

  • :ena_srd_specification (Types::EnaSrdSpecification)

    Configures ENA Express for the network interface that this action attaches to the instance.

  • :ena_queue_count (Integer)

    The number of ENA queues to be created with the instance.

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :instance_id (required, String)

    The ID of the instance.

  • :device_index (required, Integer)

    The index of the device for the network interface attachment.

Returns:



135
# File 'sig/network_interface.rbs', line 135

def attach: (

#attachmentTypes::NetworkInterfaceAttachment

The network interface attachment.



22
# File 'sig/network_interface.rbs', line 22

def attachment: () -> Types::NetworkInterfaceAttachment

#availability_zoneString

The Availability Zone.

Returns:

  • (String)


25
# File 'sig/network_interface.rbs', line 25

def availability_zone: () -> ::String

#availability_zone_idString

The ID of the Availability Zone.

Returns:

  • (String)


109
# File 'sig/network_interface.rbs', line 109

def availability_zone_id: () -> ::String

#clientClient

Returns:



252
# File 'lib/aws-sdk-ec2/network_interface.rb', line 252

def client: () -> Client

#connection_tracking_configurationTypes::ConnectionTrackingConfiguration

A security group connection tracking configuration that enables you to set the timeout for connection tracking on an Elastic network interface. For more information, see Connection tracking timeouts in the Amazon EC2 User Guide.



28
# File 'sig/network_interface.rbs', line 28

def connection_tracking_configuration: () -> Types::ConnectionTrackingConfiguration

#create_tags(options = {}) ⇒ Tag::Collection

Examples:

Request syntax with placeholder values


tag = network_interface.create_tags({
  dry_run: false,
  tags: [ # required
    {
      key: "String",
      value: "String",
    },
  ],
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :tags (required, Array<Types::Tag>)

    The tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.

Returns:



151
# File 'sig/network_interface.rbs', line 151

def create_tags: (

#dataTypes::NetworkInterface

Returns the data for this Aws::EC2::NetworkInterface. Calls Client#describe_network_interfaces if #data_loaded? is false.

Returns:



118
# File 'sig/network_interface.rbs', line 118

def data: () -> Types::NetworkInterface

#data_loaded?Boolean

Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



121
# File 'sig/network_interface.rbs', line 121

def data_loaded?: () -> bool

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


network_interface.delete({
  dry_run: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Returns:

  • (EmptyStructure)


175
# File 'sig/network_interface.rbs', line 175

def delete: (

#delete_tags(options = {}) ⇒ Tag::Collection

Examples:

Request syntax with placeholder values


tag = network_interface.delete_tags({
  dry_run: false,
  tags: [
    {
      key: "String",
      value: "String",
    },
  ],
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :tags (Array<Types::Tag>)

    The tags to delete. Specify a tag key and an optional tag value to delete specific tags. If you specify a tag key without a tag value, we delete any tag with this key regardless of its value. If you specify a tag key with an empty string as the tag value, we delete the tag only if its value is an empty string.

    If you omit this parameter, we delete all user-defined tags for the specified resources. We do not delete Amazon Web Services-generated tags (tags that have the aws: prefix).

    Constraints: Up to 1000 tags.

Returns:



163
# File 'sig/network_interface.rbs', line 163

def delete_tags: (

#deny_all_igw_trafficBoolean

Indicates whether a network interface with an IPv6 address is unreachable from the public internet. If the value is true, inbound traffic from the internet is dropped and you cannot assign an elastic IP address to the network interface. The network interface is reachable from peered VPCs and resources connected through a transit gateway, including on-premises networks.

Returns:

  • (Boolean)


94
# File 'sig/network_interface.rbs', line 94

def deny_all_igw_traffic: () -> bool

#describe_attribute(options = {}) ⇒ Types::DescribeNetworkInterfaceAttributeResult

Examples:

Request syntax with placeholder values


network_interface.describe_attribute({
  dry_run: false,
  attribute: "description", # accepts description, groupSet, sourceDestCheck, attachment, associatePublicIpAddress
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :attribute (String)

    The attribute of the network interface. This parameter is required.

Returns:



181
# File 'sig/network_interface.rbs', line 181

def describe_attribute: (

#descriptionString

A description.

Returns:

  • (String)


31
# File 'sig/network_interface.rbs', line 31

def description: () -> ::String

#detach(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


network_interface.detach({
  dry_run: false,
  force: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :force (Boolean)

    Specifies whether to force a detachment.

    * Use the Force parameter only as a last resort to detach a network interface from a failed instance.

    • If you use the Force parameter to detach a network interface, you might not be able to attach a different network interface to the same index on the instance without first stopping and starting the instance.

    • If you force the detachment of a network interface, the instance metadata might not get updated. This means that the attributes associated with the detached network interface might still be visible. The instance metadata will get updated when you stop and start the instance.

Returns:

  • (EmptyStructure)


188
# File 'sig/network_interface.rbs', line 188

def detach: (

#groupsArray<Types::GroupIdentifier>

Any security groups for the network interface.

Returns:



34
# File 'sig/network_interface.rbs', line 34

def groups: () -> ::Array[Types::GroupIdentifier]

#idString Also known as: network_interface_id

Returns:

  • (String)


18
# File 'sig/network_interface.rbs', line 18

def id: () -> String

#identifiersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.


819
820
821
# File 'lib/aws-sdk-ec2/network_interface.rb', line 819

def identifiers
  { id: @id }
end

#interface_typeString

The type of network interface.

Returns:

  • (String)


37
# File 'sig/network_interface.rbs', line 37

def interface_type: () -> ("interface" | "natGateway" | "efa" | "efa-only" | "trunk" | "load_balancer" | "network_load_balancer" | "vpc_endpoint" | "branch" | "transit_gateway" | "lambda" | "quicksight" | "global_accelerator_managed" | "api_gateway_managed" | "gateway_load_balancer" | "gateway_load_balancer_endpoint" | "iot_rules_managed" | "aws_codestar_connections_managed")

#ipv_4_prefixesArray<Types::Ipv4PrefixSpecification>

The IPv4 prefixes that are assigned to the network interface.

Returns:



67
# File 'sig/network_interface.rbs', line 67

def ipv_4_prefixes: () -> ::Array[Types::Ipv4PrefixSpecification]

#ipv_6_addressString

The IPv6 globally unique address associated with the network interface.

Returns:

  • (String)


100
# File 'sig/network_interface.rbs', line 100

def ipv_6_address: () -> ::String

#ipv_6_addressesArray<Types::NetworkInterfaceIpv6Address>

The IPv6 addresses associated with the network interface.



40
# File 'sig/network_interface.rbs', line 40

def ipv_6_addresses: () -> ::Array[Types::NetworkInterfaceIpv6Address]

#ipv_6_nativeBoolean

Indicates whether this is an IPv6 only network interface.

Returns:

  • (Boolean)


97
# File 'sig/network_interface.rbs', line 97

def ipv_6_native: () -> bool

#ipv_6_prefixesArray<Types::Ipv6PrefixSpecification>

The IPv6 prefixes that are assigned to the network interface.

Returns:



70
# File 'sig/network_interface.rbs', line 70

def ipv_6_prefixes: () -> ::Array[Types::Ipv6PrefixSpecification]

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::EC2::NetworkInterface. Returns self making it possible to chain methods.

network_interface.reload.data

Returns:

  • (self)


114
# File 'sig/network_interface.rbs', line 114

def load: () -> self

#mac_addressString

The MAC address.

Returns:

  • (String)


43
# File 'sig/network_interface.rbs', line 43

def mac_address: () -> ::String

#modify_attribute(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


network_interface.modify_attribute({
  ena_srd_specification: {
    ena_srd_enabled: false,
    ena_srd_udp_specification: {
      ena_srd_udp_enabled: false,
    },
  },
  enable_primary_ipv_6: false,
  connection_tracking_specification: {
    tcp_established_timeout: 1,
    udp_stream_timeout: 1,
    udp_timeout: 1,
  },
  associate_public_ip_address: false,
  associated_subnet_ids: ["SubnetId"],
  dry_run: false,
  description: "value", # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
  source_dest_check: {
    value: false,
  },
  groups: ["SecurityGroupId"],
  attachment: {
    default_ena_queue_count: false,
    ena_queue_count: 1,
    attachment_id: "NetworkInterfaceAttachmentId",
    delete_on_termination: false,
  },
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :ena_srd_specification (Types::EnaSrdSpecification)

    Updates the ENA Express configuration for the network interface that’s attached to the instance.

  • :enable_primary_ipv_6 (Boolean)

    If you’re modifying a network interface in a dual-stack or IPv6-only subnet, you have the option to assign a primary IPv6 IP address. A primary IPv6 address is an IPv6 GUA address associated with an ENI that you have enabled to use a primary IPv6 address. Use this option if the instance that this ENI will be attached to relies on its IPv6 address not changing. Amazon Web Services will automatically assign an IPv6 address associated with the ENI attached to your instance to be the primary IPv6 address. Once you enable an IPv6 GUA address to be a primary IPv6, you cannot disable it. When you enable an IPv6 GUA address to be a primary IPv6, the first IPv6 GUA will be made the primary IPv6 address until the instance is terminated or the network interface is detached. If you have multiple IPv6 addresses associated with an ENI attached to your instance and you enable a primary IPv6 address, the first IPv6 GUA address associated with the ENI becomes the primary IPv6 address.

  • :connection_tracking_specification (Types::ConnectionTrackingSpecificationRequest)

    A connection tracking specification.

  • :associate_public_ip_address (Boolean)

    Indicates whether to assign a public IPv4 address to a network interface. This option can be enabled for any network interface but will only apply to the primary network interface (eth0).

  • :associated_subnet_ids (Array<String>)

    A list of subnet IDs to associate with the network interface.

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :description (Types::AttributeValue)

    A description for the network interface.

  • :source_dest_check (Types::AttributeBooleanValue)

    Enable or disable source/destination checks, which ensure that the instance is either the source or the destination of any traffic that it receives. If the value is true, source/destination checks are enabled; otherwise, they are disabled. The default value is true. You must disable source/destination checks if the instance runs services such as network address translation, routing, or firewalls.

  • :groups (Array<String>)

    Changes the security groups for the network interface. The new set of groups you specify replaces the current set. You must specify at least one group, even if it's just the default security group in the VPC. You must specify the ID of the security group, not the name.

  • :attachment (Types::NetworkInterfaceAttachmentChanges)

    Information about the interface attachment. If modifying the delete on termination attribute, you must specify the ID of the interface attachment.

Returns:

  • (EmptyStructure)


195
# File 'sig/network_interface.rbs', line 195

def modify_attribute: (

#operatorTypes::OperatorResponse

The service provider that manages the network interface.



103
# File 'sig/network_interface.rbs', line 103

def operator: () -> Types::OperatorResponse

#outpost_arnString

The Amazon Resource Name (ARN) of the Outpost.

Returns:

  • (String)


46
# File 'sig/network_interface.rbs', line 46

def outpost_arn: () -> ::String

#owner_idString

The Amazon Web Services account ID of the owner of the network interface.

Returns:

  • (String)


49
# File 'sig/network_interface.rbs', line 49

def owner_id: () -> ::String

#private_dns_nameString

The private hostname. For more information, see EC2 instance hostnames, DNS names, and domains in the Amazon EC2 User Guide.

Returns:

  • (String)


52
# File 'sig/network_interface.rbs', line 52

def private_dns_name: () -> ::String

#private_ip_addressString

The IPv4 address of the network interface within the subnet.

Returns:

  • (String)


61
# File 'sig/network_interface.rbs', line 61

def private_ip_address: () -> ::String

#private_ip_addressesArray<Types::NetworkInterfacePrivateIpAddress>

The private IPv4 addresses associated with the network interface.



64
# File 'sig/network_interface.rbs', line 64

def private_ip_addresses: () -> ::Array[Types::NetworkInterfacePrivateIpAddress]

#public_dns_nameString

A public hostname. For more information, see EC2 instance hostnames, DNS names, and domains in the Amazon EC2 User Guide.

Returns:

  • (String)


55
# File 'sig/network_interface.rbs', line 55

def public_dns_name: () -> ::String

#public_ip_dns_name_optionsTypes::PublicIpDnsNameOptions

Public hostname type options. For more information, see EC2 instance hostnames, DNS names, and domains in the Amazon EC2 User Guide.



58
# File 'sig/network_interface.rbs', line 58

def public_ip_dns_name_options: () -> Types::PublicIpDnsNameOptions

#requester_idString

The alias or Amazon Web Services account ID of the principal or service that created the network interface.

Returns:

  • (String)


73
# File 'sig/network_interface.rbs', line 73

def requester_id: () -> ::String

#requester_managedBoolean

Indicates whether the network interface is being managed by Amazon Web Services.

Returns:

  • (Boolean)


76
# File 'sig/network_interface.rbs', line 76

def requester_managed: () -> bool

#reset_attribute(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


network_interface.reset_attribute({
  dry_run: false,
  source_dest_check: "String",
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :source_dest_check (String)

    The source/destination checking attribute. Resets the value to true.

Returns:

  • (EmptyStructure)


226
# File 'sig/network_interface.rbs', line 226

def reset_attribute: (

#source_dest_checkBoolean

Indicates whether source/destination checking is enabled.

Returns:

  • (Boolean)


79
# File 'sig/network_interface.rbs', line 79

def source_dest_check: () -> bool

#statusString

The status of the network interface.

Returns:

  • (String)


82
# File 'sig/network_interface.rbs', line 82

def status: () -> ("available" | "associated" | "attaching" | "in-use" | "detaching")

#subnetSubnet?

Returns:



243
# File 'sig/network_interface.rbs', line 243

def subnet: () -> Subnet?

#subnet_idString

The ID of the subnet.

Returns:

  • (String)


85
# File 'sig/network_interface.rbs', line 85

def subnet_id: () -> ::String

#tag_setArray<Types::Tag>

Any tags assigned to the network interface.

Returns:



88
# File 'sig/network_interface.rbs', line 88

def tag_set: () -> ::Array[Types::Tag]

#unassign_private_ip_addresses(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


network_interface.unassign_private_ip_addresses({
  ipv_4_prefixes: ["String"],
  private_ip_addresses: ["String"],
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :ipv_4_prefixes (Array<String>)

    The IPv4 prefixes to unassign from the network interface.

  • :private_ip_addresses (Array<String>)

    The secondary private IP addresses to unassign from the network interface. You can specify this option multiple times to unassign more than one IP address.

Returns:

  • (EmptyStructure)


233
# File 'sig/network_interface.rbs', line 233

def unassign_private_ip_addresses: (

#vpcVpc?

Returns:



246
# File 'sig/network_interface.rbs', line 246

def vpc: () -> Vpc?

#vpc_idString

The ID of the VPC.

Returns:

  • (String)


91
# File 'sig/network_interface.rbs', line 91

def vpc_id: () -> ::String

#wait_until(options = {}) {|resource| ... } ⇒ Resource

Deprecated.

Use [Aws::EC2::Client] #wait_until instead

Note:

The waiting operation is performed on a copy. The original resource remains unchanged.

Waiter polls an API operation until a resource enters a desired state.

Basic Usage

Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop until condition is true
resource.wait_until(options) {|resource| condition}

Example

instance.wait_until(max_attempts:10, delay:5) do |instance|
  instance.state.name == 'running'
end

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:

# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
  throw :failure if Time.now - started_at > 3600
end

  # disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}

Handling Errors

When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.

begin
  resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

attempts attempt in seconds invoked before each attempt invoked before each wait

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :max_attempts (Integer) — default: 10

    Maximum number of

  • :delay (Integer) — default: 10

    Delay between each

  • :before_attempt (Proc) — default: nil

    Callback

  • :before_wait (Proc) — default: nil

    Callback

Yield Parameters:

  • resource (Resource)

    to be used in the waiting condition.

Returns:

  • (Resource)

    if the waiter was successful

Raises:

  • (Aws::Waiters::Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

    yet successful.

  • (Aws::Waiters::Errors::UnexpectedError)

    Raised when an error is encountered while polling for a resource that is not expected.

  • (NotImplementedError)

    Raised when the resource does not



366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/aws-sdk-ec2/network_interface.rb', line 366

def wait_until(options = {}, &block)
  self_copy = self.dup
  attempts = 0
  options[:max_attempts] = 10 unless options.key?(:max_attempts)
  options[:delay] ||= 10
  options[:poller] = Proc.new do
    attempts += 1
    if block.call(self_copy)
      [:success, self_copy]
    else
      self_copy.reload unless attempts == options[:max_attempts]
      :retry
    end
  end
  Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    Aws::Waiters::Waiter.new(options).wait({})
  end
end