Class: AWS::EC2::ElasticIp
- Inherits:
-
Resource
- Object
- Core::Resource
- Resource
- AWS::EC2::ElasticIp
- Defined in:
- lib/aws/ec2/elastic_ip.rb
Instance Attribute Summary collapse
-
#allocation_id ⇒ Object
readonly
vpc related attributes.
-
#Indicates ⇒ String
readonly
whether this elastic ip address is for EC2 instances (‘standard’) or VPC instances (‘vpc’).
-
#instance_id ⇒ String?
readonly
Returns the instance id if assigned to an EC2 instance, nil otherwise.
-
#network_interface_owner_id ⇒ String?
readonly
The ID of the AWS account that owns the network interface (VPC only).
-
#public_ip ⇒ String
(also: #ip_address)
readonly
The public IP address.
-
#The ⇒ String?
readonly
ID of the association between this elastic ip address and an EC2 VPC instance (VPC only).
Attributes included from Core::Model
Instance Method Summary collapse
-
#associated? ⇒ Boolean
(also: #attached?)
Returns true if this IP address is attached to an EC2 instance.
-
#delete ⇒ nil
(also: #release)
Releases the elastic IP address.
-
#disassociate ⇒ nil
Disassociates this elastic IP address from an EC2 instance.
-
#exists? ⇒ Boolean
Returns true the elastic ip address exists in your account.
-
#initialize(public_ip, options = {}) ⇒ ElasticIp
constructor
A new instance of ElasticIp.
-
#instance ⇒ Instance?
If associated, returns the Instance this elastic IP address is associated to, nil otherwise.
-
#to_s ⇒ String
Returns the public IP address.
-
#vpc? ⇒ Boolean
Returns true if this is an EC2 VPC Elastic IP.
Methods inherited from Core::Resource
attribute_providers, attribute_providers_for, attributes, #attributes_from_response, define_attribute_type, #eql?, #inspect, new_from
Methods included from Core::Cacheable
Methods included from Core::Model
#client, #config_prefix, #inspect
Constructor Details
#initialize(public_ip, options = {}) ⇒ ElasticIp
Returns a new instance of ElasticIp.
37 38 39 40 |
# File 'lib/aws/ec2/elastic_ip.rb', line 37 def initialize public_ip, = {} @public_ip = public_ip super end |
Instance Attribute Details
#allocation_id ⇒ Object (readonly)
vpc related attributes
35 36 37 |
# File 'lib/aws/ec2/elastic_ip.rb', line 35 def allocation_id @allocation_id end |
#Indicates ⇒ String (readonly)
whether this elastic ip address is for EC2 instances (‘standard’) or VPC instances (‘vpc’).
35 36 37 |
# File 'lib/aws/ec2/elastic_ip.rb', line 35 def Indicates @Indicates end |
#instance_id ⇒ String? (readonly)
Returns the instance id if assigned to an EC2 instance, nil otherwise.
35 36 37 |
# File 'lib/aws/ec2/elastic_ip.rb', line 35 def instance_id @instance_id end |
#network_interface_owner_id ⇒ String? (readonly)
The ID of the AWS account that owns the network interface (VPC only).
35 36 37 |
# File 'lib/aws/ec2/elastic_ip.rb', line 35 def network_interface_owner_id @network_interface_owner_id end |
#public_ip ⇒ String (readonly) Also known as: ip_address
Returns The public IP address.
43 44 45 |
# File 'lib/aws/ec2/elastic_ip.rb', line 43 def public_ip @public_ip end |
#The ⇒ String? (readonly)
ID of the association between this elastic ip address and an EC2 VPC instance (VPC only).
35 36 37 |
# File 'lib/aws/ec2/elastic_ip.rb', line 35 def The @The end |
Instance Method Details
#associated? ⇒ Boolean Also known as: attached?
Returns true if this IP address is attached to an EC2 instance.
72 73 74 |
# File 'lib/aws/ec2/elastic_ip.rb', line 72 def associated? !!instance_id end |
#delete ⇒ nil Also known as: release
Releases the elastic IP address.
(For non-VPC elastic ips) Releasing an IP address automatically disassociates it from any instance it’s associated with.
92 93 94 95 96 97 98 99 |
# 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 |
#disassociate ⇒ nil
Disassociates this elastic IP address from an EC2 instance. Raises an exception if this elastic IP is not currently associated with an instance.
106 107 108 109 110 111 112 113 |
# 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? ⇒ Boolean
Returns true the elastic ip address exists in your account.
117 118 119 120 121 122 123 124 |
# File 'lib/aws/ec2/elastic_ip.rb', line 117 def exists? begin get_resource true rescue Errors::InvalidAddress::NotFound false end end |
#instance ⇒ Instance?
Returns If associated, returns the Instance this elastic IP address is associated to, nil otherwise.
80 81 82 83 84 |
# 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 |
#to_s ⇒ String
Returns the public IP address
127 128 129 |
# File 'lib/aws/ec2/elastic_ip.rb', line 127 def to_s public_ip.to_s end |
#vpc? ⇒ Boolean
Returns true if this is an EC2 VPC Elastic IP.
66 67 68 |
# File 'lib/aws/ec2/elastic_ip.rb', line 66 def vpc? domain == 'vpc' end |