Class: AWS::EC2::ElasticIpCollection

Inherits:
Collection
  • Object
show all
Defined in:
lib/aws/ec2/elastic_ip_collection.rb

Instance Method Summary collapse

Instance Method Details

#[](public_ip) ⇒ ElasticIp

Returns The elastic IP with the given address.

Parameters:

  • public_ip (String)

    The public IP address of an elastic ip.

Returns:

  • (ElasticIp)

    The elastic IP with the given address.



31
32
33
# File 'lib/aws/ec2/elastic_ip_collection.rb', line 31

def [] public_ip
  super
end

#createObject Also known as: allocate



22
23
24
25
# File 'lib/aws/ec2/elastic_ip_collection.rb', line 22

def create 
  response = client.allocate_address
  ElasticIp.new(response.public_ip, :config => config)
end

#each {|elastic_ip| ... } ⇒ Object

Yields once for each elastic IP address.

Yields:

  • (elastic_ip)

Yield Parameters:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/aws/ec2/elastic_ip_collection.rb', line 66

def each &block
  response = filtered_request(:describe_addresses)
  response.addresses_set.each do |address|

    options = {}
    options[:config] = config
    options[:instance_id] = address.instance_id

    elastic_ip = ElasticIp.new(address.public_ip, options)

    yield(elastic_ip)

  end
end