Class: AWS::EC2::NetworkInterfaceCollection

Inherits:
Collection
  • Object
show all
Includes:
Core::Collection::Simple, TaggedCollection
Defined in:
lib/aws/ec2/network_interface_collection.rb

Instance Attribute Summary

Attributes included from Core::Model

#config

Instance Method Summary collapse

Methods included from Core::Collection::Simple

#each_batch

Methods included from Core::Collection

#each, #each_batch, #enum, #first, #in_groups_of, #page

Methods included from Core::Model

#client, #config_prefix, #initialize, #inspect

Methods included from TaggedCollection

#tagged, #tagged_values

Methods included from FilteredCollection

#filter, #filtered_request, #initialize

Instance Method Details

#[](network_interface_id) ⇒ NetworkInterface



66
67
68
# File 'lib/aws/ec2/network_interface_collection.rb', line 66

def [] network_interface_id
  NetworkInterface.new(network_interface_id, :config => config)
end

#create(options = {}) ⇒ NetworkInterface

Creates a network interface.

Options Hash (options):

  • :subnet (Subnet, String)

    The subnet or subnet id to associate with the network interface.

  • :private_ip_address (String)

    The private IP address of the network interface.

  • :description (String)

    The description of the network interface.

  • :security_groups (Array<SecurityGroup>, Array<String>)

    A list of security groups (or security group id strings) that should be used by this network interface.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/aws/ec2/network_interface_collection.rb', line 40

def create options = {}

  client_opts = {}

  client_opts[:subnet_id] = subnet_id_option(options)

  client_opts[:private_ip_address] = options[:private_ip_address] if
    options.key?(:private_ip_address)

  client_opts[:description] = options[:description] if
    options.key?(:description)

  groups = groups_options(options)
  client_opts[:groups] = groups if groups
  
  resp = client.create_network_interface(client_opts)

  NetworkInterface.new_from(:create_network_interface,
    resp.network_interface, 
    resp.network_interface.network_interface_id, 
    :config => config)

end