Class: AWS::EC2::ElasticIp
- Inherits:
-
Resource
- Object
- 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.
25 26 27 28 |
# File 'lib/aws/ec2/elastic_ip.rb', line 25 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.
23 24 25 |
# File 'lib/aws/ec2/elastic_ip.rb', line 23 def instance_id @instance_id end |
#public_ip ⇒ String (readonly) Also known as: ip_address
Returns The public IP address.
31 32 33 |
# File 'lib/aws/ec2/elastic_ip.rb', line 31 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.
43 44 45 |
# File 'lib/aws/ec2/elastic_ip.rb', line 43 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.
63 64 65 66 |
# File 'lib/aws/ec2/elastic_ip.rb', line 63 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.
74 75 76 77 |
# File 'lib/aws/ec2/elastic_ip.rb', line 74 def disassociate client.disassociate_address() nil end |
#instance ⇒ Instance?
Returns If associated, returns the Instance this elastic IP address is associated to, nil otherwise.
51 52 53 54 55 |
# File 'lib/aws/ec2/elastic_ip.rb', line 51 def instance if instance_id = self.instance_id Instance.new(instance_id, :config => config) end end |
#to_s ⇒ String
Returns the public IP address
80 81 82 |
# File 'lib/aws/ec2/elastic_ip.rb', line 80 def to_s public_ip.to_s end |