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
-
#instance_id ⇒ String?
readonly
Returns the instance id if assigned to an EC2 instance, nil otherwise.
-
#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 ⇒ nil
(also: #release)
Releases the elastic IP address.
-
#disassociate ⇒ nil
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.
-
#to_s ⇒ String
Returns the public IP address.
Constructor Details
#initialize(public_ip, options = {}) ⇒ ElasticIp
Returns a new instance of ElasticIp.
23 24 25 26 |
# File 'lib/aws/ec2/elastic_ip.rb', line 23 def initialize public_ip, = {} @public_ip = public_ip super end |
Instance Attribute Details
#instance_id ⇒ String? (readonly)
Returns the instance id if assigned to an EC2 instance, nil otherwise.
21 22 23 |
# File 'lib/aws/ec2/elastic_ip.rb', line 21 def instance_id @instance_id end |
#public_ip ⇒ String (readonly) Also known as: ip_address
Returns The public IP address.
29 30 31 |
# File 'lib/aws/ec2/elastic_ip.rb', line 29 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.
41 42 43 |
# File 'lib/aws/ec2/elastic_ip.rb', line 41 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.
61 62 63 64 |
# File 'lib/aws/ec2/elastic_ip.rb', line 61 def delete client.release_address() 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.
72 73 74 75 |
# File 'lib/aws/ec2/elastic_ip.rb', line 72 def disassociate client.disassociate_address() nil end |
#instance ⇒ Instance?
Returns If associated, returns the Instance this elastic IP address is associated to, nil otherwise.
49 50 51 52 53 |
# File 'lib/aws/ec2/elastic_ip.rb', line 49 def instance if instance_id = self.instance_id Instance.new(instance_id, :config => config) end end |
#to_s ⇒ String
Returns the public IP address
78 79 80 |
# File 'lib/aws/ec2/elastic_ip.rb', line 78 def to_s public_ip.to_s end |