Class: Aws::EC2::NetworkInterface
- Inherits:
-
Object
- Object
- Aws::EC2::NetworkInterface
- Defined in:
- gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#associated_subnets ⇒ Array<String>
The subnets associated with this network interface.
-
#attachment ⇒ Types::NetworkInterfaceAttachment
The network interface attachment.
-
#availability_zone ⇒ String
The Availability Zone.
-
#availability_zone_id ⇒ String
The ID of the Availability Zone.
-
#connection_tracking_configuration ⇒ Types::ConnectionTrackingConfiguration
A security group connection tracking configuration that enables you to set the timeout for connection tracking on an Elastic network interface.
-
#deny_all_igw_traffic ⇒ Boolean
Indicates whether a network interface with an IPv6 address is unreachable from the public internet.
-
#description ⇒ String
A description.
-
#groups ⇒ Array<Types::GroupIdentifier>
Any security groups for the network interface.
-
#id ⇒ String
(also: #network_interface_id)
-
#interface_type ⇒ String
The type of network interface.
-
#ipv_4_prefixes ⇒ Array<Types::Ipv4PrefixSpecification>
The IPv4 prefixes that are assigned to the network interface.
-
#ipv_6_address ⇒ String
The IPv6 globally unique address associated with the network interface.
-
#ipv_6_addresses ⇒ Array<Types::NetworkInterfaceIpv6Address>
The IPv6 addresses associated with the network interface.
-
#ipv_6_native ⇒ Boolean
Indicates whether this is an IPv6 only network interface.
-
#ipv_6_prefixes ⇒ Array<Types::Ipv6PrefixSpecification>
The IPv6 prefixes that are assigned to the network interface.
-
#mac_address ⇒ String
The MAC address.
-
#operator ⇒ Types::OperatorResponse
The service provider that manages the network interface.
-
#outpost_arn ⇒ String
The Amazon Resource Name (ARN) of the Outpost.
-
#owner_id ⇒ String
The Amazon Web Services account ID of the owner of the network interface.
-
#private_dns_name ⇒ String
The private hostname.
-
#private_ip_address ⇒ String
The IPv4 address of the network interface within the subnet.
-
#private_ip_addresses ⇒ Array<Types::NetworkInterfacePrivateIpAddress>
The private IPv4 addresses associated with the network interface.
-
#public_dns_name ⇒ String
A public hostname.
-
#public_ip_dns_name_options ⇒ Types::PublicIpDnsNameOptions
Public hostname type options.
-
#requester_id ⇒ String
The alias or Amazon Web Services account ID of the principal or service that created the network interface.
-
#requester_managed ⇒ Boolean
Indicates whether the network interface is being managed by Amazon Web Services.
-
#source_dest_check ⇒ Boolean
Indicates whether source/destination checking is enabled.
-
#status ⇒ String
The status of the network interface.
-
#subnet_id ⇒ String
The ID of the subnet.
-
#tag_set ⇒ Array<Types::Tag>
Any tags assigned to the network interface.
-
#vpc_id ⇒ String
The ID of the VPC.
Actions collapse
-
#assign_private_ip_addresses(options = {}) ⇒ Types::AssignPrivateIpAddressesResult
-
#attach(options = {}) ⇒ Types::AttachNetworkInterfaceResult
-
#create_tags(options = {}) ⇒ Tag::Collection
-
#delete(options = {}) ⇒ EmptyStructure
-
#delete_tags(options = {}) ⇒ Tag::Collection
-
#describe_attribute(options = {}) ⇒ Types::DescribeNetworkInterfaceAttributeResult
-
#detach(options = {}) ⇒ EmptyStructure
-
#modify_attribute(options = {}) ⇒ EmptyStructure
-
#reset_attribute(options = {}) ⇒ EmptyStructure
-
#unassign_private_ip_addresses(options = {}) ⇒ EmptyStructure
Associations collapse
Instance Method Summary collapse
-
#client ⇒ Client
-
#data ⇒ Types::NetworkInterface
Returns the data for this NetworkInterface.
-
#data_loaded? ⇒ Boolean
Returns
trueif this resource is loaded. -
#initialize(*args) ⇒ NetworkInterface
constructor
A new instance of NetworkInterface.
-
#load ⇒ self
(also: #reload)
Loads, or reloads #data for the current NetworkInterface.
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::EC2::Client] #wait_until instead
Constructor Details
#initialize(id, options = {}) ⇒ NetworkInterface #initialize(options = {}) ⇒ NetworkInterface
Returns a new instance of NetworkInterface.
22 23 24 25 26 27 28 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 22 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @id = extract_id(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#assign_private_ip_addresses(options = {}) ⇒ Types::AssignPrivateIpAddressesResult
420 421 422 423 424 425 426 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 420 def assign_private_ip_addresses( = {}) = .merge(network_interface_id: @id) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.assign_private_ip_addresses() end resp.data end |
#associated_subnets ⇒ Array<String>
The subnets associated with this network interface.
239 240 241 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 239 def associated_subnets data[:associated_subnets] end |
#association ⇒ NetworkInterfaceAssociation?
781 782 783 784 785 786 787 788 789 790 791 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 781 def association if data[:association][:association_id] NetworkInterfaceAssociation.new( id: data[:association][:association_id], data: data[:association], client: @client ) else nil end end |
#attach(options = {}) ⇒ Types::AttachNetworkInterfaceResult
463 464 465 466 467 468 469 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 463 def attach( = {}) = .merge(network_interface_id: @id) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.attach_network_interface() end resp.data end |
#attachment ⇒ Types::NetworkInterfaceAttachment
The network interface attachment.
40 41 42 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 40 def data[:attachment] end |
#availability_zone ⇒ String
The Availability Zone.
46 47 48 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 46 def availability_zone data[:availability_zone] end |
#availability_zone_id ⇒ String
The ID of the Availability Zone.
245 246 247 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 245 def availability_zone_id data[:availability_zone_id] end |
#client ⇒ Client
252 253 254 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 252 def client @client end |
#connection_tracking_configuration ⇒ Types::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.
59 60 61 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 59 def connection_tracking_configuration data[:connection_tracking_configuration] end |
#create_tags(options = {}) ⇒ Tag::Collection
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 493 def ( = {}) batch = [] = Aws::Util.deep_merge(, resources: [@id]) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.() end [:tags].each do |t| batch << Tag.new( resource_id: @id, key: t[:key], value: t[:value], client: @client ) end Tag::Collection.new([batch], size: batch.size) end |
#data ⇒ Types::NetworkInterface
Returns the data for this Aws::EC2::NetworkInterface. Calls
Client#describe_network_interfaces if #data_loaded? is false.
274 275 276 277 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 274 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
282 283 284 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 282 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
569 570 571 572 573 574 575 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 569 def delete( = {}) = .merge(network_interface_id: @id) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.delete_network_interface() end resp.data end |
#delete_tags(options = {}) ⇒ Tag::Collection
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 540 def ( = {}) batch = [] = Aws::Util.deep_merge(, resources: [@id]) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.() end [:tags].each do |t| batch << Tag.new( resource_id: @id, key: t[:key], value: t[:value], client: @client ) end Tag::Collection.new([batch], size: batch.size) end |
#deny_all_igw_traffic ⇒ Boolean
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.
214 215 216 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 214 def deny_all_igw_traffic data[:deny_all_igw_traffic] end |
#describe_attribute(options = {}) ⇒ Types::DescribeNetworkInterfaceAttributeResult
592 593 594 595 596 597 598 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 592 def describe_attribute( = {}) = .merge(network_interface_id: @id) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_network_interface_attribute() end resp.data end |
#description ⇒ String
A description.
65 66 67 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 65 def description data[:description] end |
#detach(options = {}) ⇒ EmptyStructure
635 636 637 638 639 640 641 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 635 def detach( = {}) = .merge(attachment_id: data[:attachment][:attachment_id]) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.detach_network_interface() end resp.data end |
#groups ⇒ Array<Types::GroupIdentifier>
Any security groups for the network interface.
71 72 73 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 71 def groups data[:groups] end |
#id ⇒ String Also known as: network_interface_id
33 34 35 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 33 def id @id end |
#interface_type ⇒ String
The type of network interface.
77 78 79 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 77 def interface_type data[:interface_type] end |
#ipv_4_prefixes ⇒ Array<Types::Ipv4PrefixSpecification>
The IPv4 prefixes that are assigned to the network interface.
153 154 155 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 153 def ipv_4_prefixes data[:ipv_4_prefixes] end |
#ipv_6_address ⇒ String
The IPv6 globally unique address associated with the network interface.
227 228 229 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 227 def ipv_6_address data[:ipv_6_address] end |
#ipv_6_addresses ⇒ Array<Types::NetworkInterfaceIpv6Address>
The IPv6 addresses associated with the network interface.
83 84 85 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 83 def ipv_6_addresses data[:ipv_6_addresses] end |
#ipv_6_native ⇒ Boolean
Indicates whether this is an IPv6 only network interface.
220 221 222 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 220 def ipv_6_native data[:ipv_6_native] end |
#ipv_6_prefixes ⇒ Array<Types::Ipv6PrefixSpecification>
The IPv6 prefixes that are assigned to the network interface.
159 160 161 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 159 def ipv_6_prefixes data[:ipv_6_prefixes] end |
#load ⇒ self 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
262 263 264 265 266 267 268 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 262 def load resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_network_interfaces(network_interface_ids: [@id]) end @data = resp.network_interfaces[0] self end |
#mac_address ⇒ String
The MAC address.
89 90 91 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 89 def mac_address data[:mac_address] end |
#modify_attribute(options = {}) ⇒ EmptyStructure
725 726 727 728 729 730 731 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 725 def modify_attribute( = {}) = .merge(network_interface_id: @id) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.modify_network_interface_attribute() end resp.data end |
#operator ⇒ Types::OperatorResponse
The service provider that manages the network interface.
233 234 235 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 233 def operator data[:operator] end |
#outpost_arn ⇒ String
The Amazon Resource Name (ARN) of the Outpost.
95 96 97 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 95 def outpost_arn data[:outpost_arn] end |
#owner_id ⇒ String
The Amazon Web Services account ID of the owner of the network interface.
102 103 104 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 102 def owner_id data[:owner_id] end |
#private_dns_name ⇒ String
The private hostname. For more information, see EC2 instance hostnames, DNS names, and domains in the Amazon EC2 User Guide.
113 114 115 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 113 def private_dns_name data[:private_dns_name] end |
#private_ip_address ⇒ String
The IPv4 address of the network interface within the subnet.
141 142 143 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 141 def private_ip_address data[:private_ip_address] end |
#private_ip_addresses ⇒ Array<Types::NetworkInterfacePrivateIpAddress>
The private IPv4 addresses associated with the network interface.
147 148 149 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 147 def private_ip_addresses data[:private_ip_addresses] end |
#public_dns_name ⇒ String
A public hostname. For more information, see EC2 instance hostnames, DNS names, and domains in the Amazon EC2 User Guide.
124 125 126 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 124 def public_dns_name data[:public_dns_name] end |
#public_ip_dns_name_options ⇒ Types::PublicIpDnsNameOptions
Public hostname type options. For more information, see EC2 instance hostnames, DNS names, and domains in the Amazon EC2 User Guide.
135 136 137 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 135 def data[:public_ip_dns_name_options] end |
#requester_id ⇒ String
The alias or Amazon Web Services account ID of the principal or service that created the network interface.
166 167 168 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 166 def requester_id data[:requester_id] end |
#requester_managed ⇒ Boolean
Indicates whether the network interface is being managed by Amazon Web Services.
173 174 175 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 173 def requester_managed data[:requester_managed] end |
#reset_attribute(options = {}) ⇒ EmptyStructure
748 749 750 751 752 753 754 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 748 def reset_attribute( = {}) = .merge(network_interface_id: @id) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.reset_network_interface_attribute() end resp.data end |
#source_dest_check ⇒ Boolean
Indicates whether source/destination checking is enabled.
179 180 181 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 179 def source_dest_check data[:source_dest_check] end |
#status ⇒ String
The status of the network interface.
185 186 187 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 185 def status data[:status] end |
#subnet ⇒ Subnet?
794 795 796 797 798 799 800 801 802 803 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 794 def subnet if data[:subnet_id] Subnet.new( id: data[:subnet_id], client: @client ) else nil end end |
#subnet_id ⇒ String
The ID of the subnet.
191 192 193 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 191 def subnet_id data[:subnet_id] end |
#tag_set ⇒ Array<Types::Tag>
Any tags assigned to the network interface.
197 198 199 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 197 def tag_set data[:tag_set] end |
#unassign_private_ip_addresses(options = {}) ⇒ EmptyStructure
770 771 772 773 774 775 776 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 770 def unassign_private_ip_addresses( = {}) = .merge(network_interface_id: @id) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.unassign_private_ip_addresses() end resp.data end |
#vpc ⇒ Vpc?
806 807 808 809 810 811 812 813 814 815 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 806 def vpc if data[:vpc_id] Vpc.new( id: data[:vpc_id], client: @client ) else nil end end |
#vpc_id ⇒ String
The ID of the VPC.
203 204 205 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 203 def vpc_id data[:vpc_id] end |
#wait_until(options = {}) {|resource| ... } ⇒ Resource
Use [Aws::EC2::Client] #wait_until instead
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() {|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
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/network_interface.rb', line 366 def wait_until( = {}, &block) self_copy = self.dup attempts = 0 [:max_attempts] = 10 unless .key?(:max_attempts) [:delay] ||= 10 [:poller] = Proc.new do attempts += 1 if block.call(self_copy) [:success, self_copy] else self_copy.reload unless attempts == [:max_attempts] :retry end end Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do Aws::Waiters::Waiter.new().wait({}) end end |