Class: AWS::EC2::ElasticIp
- Inherits:
-
Resource
- Object
- Resource
- AWS::EC2::ElasticIp
- Defined in:
- lib/aws/ec2/elastic_ip.rb
Instance Attribute Summary collapse
-
#public_ip ⇒ String
(also: #ip_address)
readonly
The public IP address.
Instance Method Summary collapse
-
#associated? ⇒ Boolean
(also: #attached?)
Returns true if this IP address is attached to an EC2 instance.
-
#delete ⇒ true
(also: #release)
Releases the elastic IP address.
-
#disassociate ⇒ true
Disassociates this elastic IP address from an EC2 instance.
-
#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.
-
#instance_id ⇒ String?
Returns the instance id if assigned to an EC2 instance.
Constructor Details
#initialize(public_ip, options = {}) ⇒ ElasticIp
Returns a new instance of ElasticIp.
20 21 22 23 24 |
# File 'lib/aws/ec2/elastic_ip.rb', line 20 def initialize public_ip, = {} @public_ip = public_ip @instance_id = [:instance_id] super end |
Instance Attribute Details
#public_ip ⇒ String (readonly) Also known as: ip_address
Returns The public IP address.
33 34 35 |
# File 'lib/aws/ec2/elastic_ip.rb', line 33 def public_ip @public_ip end |
Instance Method Details
#associated? ⇒ Boolean Also known as: attached?
Returns true if this IP address is attached to an EC2 instance.
44 45 46 |
# File 'lib/aws/ec2/elastic_ip.rb', line 44 def associated? !!instance_id end |
#delete ⇒ true 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.
61 62 63 64 |
# File 'lib/aws/ec2/elastic_ip.rb', line 61 def delete client.release_address(:public_ip => public_ip) true end |
#disassociate ⇒ true
Disassociates this elastic IP address from an EC2 instance. Raises an exception if this elastic IP is not currently associated with an instance.
72 73 74 75 |
# File 'lib/aws/ec2/elastic_ip.rb', line 72 def disassociate client.disassociate_address(:public_ip => public_ip) true end |
#instance ⇒ Instance?
Returns If associated, returns the Instance this elastic IP address is associated to, nil otherwise.
51 52 53 |
# File 'lib/aws/ec2/elastic_ip.rb', line 51 def instance associated? ? Instance.new(instance_id, :config => config) : nil end |
#instance_id ⇒ String?
Returns the instance id if assigned to an EC2 instance
39 |
# File 'lib/aws/ec2/elastic_ip.rb', line 39 def instance_id; end |