class AWS::EC2::NetworkInterface
Represents a network interface in EC2
.
@attr [String] description
@attr_reader [String] vpc_id
@attr_reader [String] subnet_id
@attr_reader [String] owner_id
@attr_reader [Symbol] status
@attr_reader [String] private_ip_address
@attr_reader [Array<Hash>] private_ip_addresses Returns an array
of private ip addresses with the following keys: * `:private_ip_address` (String) * `:primary` (boolean)
@attr_reader [String] private_dns_name
@attr_reader [String] availability_zone_name
@attr_reader [String] mac_address
@attr_reader [Hash,nil] association Returns a hash of
details about the association between this network interface and an elastic ip address.
@attr [Boolean] source_dest_check
@attr [Boolean] requester_managed
Attributes
@return [String]
@return [String]
Public Class Methods
# File lib/aws/ec2/network_interface.rb, line 56 def initialize network_interface_id, options = {} @network_interface_id = network_interface_id super end
Public Instance Methods
@param [Instance,String] instance The instance to attach this network
interface to, may be an {Instance} object or an instance id string.
@param [Hash] options
@option options [Integer] :device_index (1) The index of the device
for the network interface attachment on the instance. Defaults to 1.
@return [nil]
# File lib/aws/ec2/network_interface.rb, line 189 def attach instance, options = {} instance_id = instance.is_a?(Instance) ? instance.instance_id : instance client_opts = {} client_opts[:network_interface_id] = network_interface_id client_opts[:instance_id] = instance_id client_opts[:device_index] = options[:device_index] || 1 client.attach_network_interface(client_opts) nil end
@return [Attachment,nil]
# File lib/aws/ec2/network_interface.rb, line 173 def attachment if details = attachment_details Attachment.new(self, details) end end
@return [AvailabilityZone]
# File lib/aws/ec2/network_interface.rb, line 138 def availability_zone AvailabilityZone.new(availability_zone_name, :config => config) end
Deletes this network interface. @return [nil]
# File lib/aws/ec2/network_interface.rb, line 218 def delete client_opts = {} client_opts[:network_interface_id] = network_interface_id client.delete_network_interface(client_opts) nil end
Detaches this network interface. @param [Hash] options @option (see NetworkInterface::Attachment#detach
) @return (see NetworkInterface::Attachment#detach
)
# File lib/aws/ec2/network_interface.rb, line 208 def detach options = {} if attachment = self.attachment attachment.detach(options) else raise 'unable to detach network interface, no attachment present' end end
@return [ElasticIp,nil]
# File lib/aws/ec2/network_interface.rb, line 130 def elastic_ip if association = self.association opts = association.merge(:config => config) ElasticIp.new(association[:public_ip], opts) end end
@return [Boolean] Returns true if this network interface exists.
# File lib/aws/ec2/network_interface.rb, line 226 def exists? begin get_resource true rescue Errors::InvalidNetworkInterfaceID::NotFound false end end
@return [Instance,nil] Returns the instance this network interface
is attached to. If it has not been attached, then nil is returned.
# File lib/aws/ec2/network_interface.rb, line 166 def instance if attachment = self.attachment attachment.instance end end
@return [Array<SecurityGroup>]
# File lib/aws/ec2/network_interface.rb, line 143 def security_groups groups.collect do |g| SecurityGroup.new(g.group_id, :name => g.group_name, :config => config) end end
@param [Array<SecurityGroup>,Array<String>] groups A list of
security groups objects or security group ids. This replaces the security group set on this network interface.
@return [nil]
# File lib/aws/ec2/network_interface.rb, line 155 def set_security_groups *groups self.groups = [groups].flatten.collect do |g| g.is_a?(SecurityGroup) ? g.security_group_id : g end nil end
@return [Subnet] Returns the Subnet
this network interface
belongs to.
# File lib/aws/ec2/network_interface.rb, line 125 def subnet Subnet.new(subnet_id, :vpc_id => vpc_id, :config => config) end
@return [VPC] Returns the VPC
this network interface belongs to.
# File lib/aws/ec2/network_interface.rb, line 119 def vpc VPC.new(vpc_id, :config => config) end