class AWS::EC2::ElasticIp

@attr_reader [String,nil] instance_id Returns the instance id if

assigned to an EC2 instance, nil otherwise.

@attr_reader [String,nil] allocation_id

The ID representing the allocation of the address for use with Amazon 
VPC.

@attr_reader [String] Indicates whether this elastic ip address is for

EC2 instances ('standard') or VPC instances ('vpc').

@attr_reader [String,nil] The ID of the association between this elastic

ip address and an EC2 VPC instance (VPC only).

@attr_reader [String,nil] The ID of the network interface (VPC only).

@attr_reader [String,nil] network_interface_owner_id

The ID of the AWS account that owns the network interface (VPC only).

Attributes

ip_address[R]

@return [String] The public IP address.

public_ip[R]

@return [String] The public IP address.

Public Class Methods

new(public_ip, options = {}) click to toggle source
# File lib/aws/ec2/elastic_ip.rb, line 37
def initialize public_ip, options = {}
  @public_ip = public_ip
  super
end

Protected Class Methods

describe_call_name() click to toggle source

@private

# File lib/aws/ec2/elastic_ip.rb, line 151
def self.describe_call_name
  :describe_addresses
end

Public Instance Methods

associated?() click to toggle source

@return [Boolean] Returns true if this IP address is attached to

an EC2 instance.
# File lib/aws/ec2/elastic_ip.rb, line 72
def associated?
  !!instance_id
end
Also aliased as: attached?
attached?() click to toggle source
Alias for: associated?
delete() click to toggle source

Releases the elastic IP address.

(For non-VPC elastic ips) Releasing an IP address automatically disassociates it from any instance it's associated with.

@return [nil]

# File lib/aws/ec2/elastic_ip.rb, line 92
def delete
  if vpc?
    client.release_address(:allocation_id => allocation_id)
  else
    client.release_address(:public_ip => public_ip)
  end
  nil
end
Also aliased as: release
disassociate() click to toggle source

Disassociates this elastic IP address from an EC2 instance. Raises an exception if this elastic IP is not currently associated with an instance. @return [nil]

# File lib/aws/ec2/elastic_ip.rb, line 106
def disassociate
  if vpc?
    client.disassociate_address(:association_id => association_id)
  else
    client.disassociate_address(:public_ip => public_ip)
  end
  nil
end
exists?() click to toggle source

@return [Boolean] Returns true the elastic ip address exists in

your account.
# File lib/aws/ec2/elastic_ip.rb, line 117
def exists?
  begin
    get_resource
    true
  rescue Errors::InvalidAddress::NotFound
    false
  end
end
instance() click to toggle source

@return [Instance,nil] If associated, returns the {Instance} this

elastic IP address is associated to, nil otherwise.
# File lib/aws/ec2/elastic_ip.rb, line 80
def instance
  if instance_id = self.instance_id
    Instance.new(instance_id, :config => config)
  end
end
release() click to toggle source
Alias for: delete
to_s() click to toggle source

@return [String] Returns the public IP address

# File lib/aws/ec2/elastic_ip.rb, line 127
def to_s
  public_ip.to_s
end
vpc?() click to toggle source

@return [Boolean] Returns true if this is an EC2 VPC Elastic IP.

# File lib/aws/ec2/elastic_ip.rb, line 66
def vpc?
  domain == 'vpc'
end

Protected Instance Methods

describe_call_name() click to toggle source

@private

# File lib/aws/ec2/elastic_ip.rb, line 145
def describe_call_name
  :describe_addresses
end
resource_id_method() click to toggle source

@private

# File lib/aws/ec2/elastic_ip.rb, line 133
def resource_id_method
  :public_ip
end
response_id_method() click to toggle source

@private

# File lib/aws/ec2/elastic_ip.rb, line 139
def response_id_method
  :public_ip
end