Class: Aws::EC2::VpcAddress
- Inherits:
-
Object
- Object
- Aws::EC2::VpcAddress
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-ec2/vpc_address.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
- #allocation_id ⇒ String
-
#association_id ⇒ String
The ID representing the association of the address with an instance in a VPC.
-
#domain ⇒ String
Indicates whether this Elastic IP address is for use with instances in EC2-Classic (‘standard`) or instances in a VPC (`vpc`).
-
#instance_id ⇒ String
The ID of the instance that the address is associated with (if any).
-
#network_interface_id ⇒ String
The ID of the network interface.
-
#network_interface_owner_id ⇒ String
The ID of the AWS account that owns the network interface.
-
#private_ip_address ⇒ String
The private IP address associated with the Elastic IP address.
-
#public_ip ⇒ String
The Elastic IP address.
-
#public_ipv_4_pool ⇒ String
The ID of an address pool.
-
#tags ⇒ Array<Types::Tag>
Any tags assigned to the Elastic IP address.
Actions collapse
Associations collapse
- #association ⇒ NetworkInterfaceAssociation?
- #identifiers ⇒ Object deprecated private Deprecated.
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::Address
Returns the data for this VpcAddress.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#initialize(*args) ⇒ VpcAddress
constructor
A new instance of VpcAddress.
-
#load ⇒ self
(also: #reload)
Loads, or reloads #data for the current VpcAddress.
-
#wait_until(options = {}, &block) ⇒ Resource
deprecated
Deprecated.
Use [Aws::EC2::Client] #wait_until instead
Constructor Details
#initialize(allocation_id, options = {}) ⇒ VpcAddress #initialize(options = {}) ⇒ VpcAddress
Returns a new instance of VpcAddress.
19 20 21 22 23 24 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 19 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @allocation_id = extract_allocation_id(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() end |
Instance Method Details
#allocation_id ⇒ String
29 30 31 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 29 def allocation_id @allocation_id end |
#associate(options = {}) ⇒ Types::AssociateAddressResult
261 262 263 264 265 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 261 def associate( = {}) = .merge(allocation_id: @allocation_id) resp = @client.associate_address() resp.data end |
#association ⇒ NetworkInterfaceAssociation?
291 292 293 294 295 296 297 298 299 300 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 291 def association if data[:association_id] NetworkInterfaceAssociation.new( id: data[:association_id], client: @client ) else nil end end |
#association_id ⇒ String
The ID representing the association of the address with an instance in a VPC.
48 49 50 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 48 def association_id data[:association_id] end |
#data ⇒ Types::Address
Returns the data for this Aws::EC2::VpcAddress. Calls Client#describe_addresses if #data_loaded? is ‘false`.
112 113 114 115 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 112 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
120 121 122 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 120 def data_loaded? !!@data end |
#domain ⇒ String
Indicates whether this Elastic IP address is for use with instances in EC2-Classic (‘standard`) or instances in a VPC (`vpc`).
55 56 57 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 55 def domain data[:domain] end |
#identifiers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
304 305 306 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 304 def identifiers { allocation_id: @allocation_id } end |
#instance_id ⇒ String
The ID of the instance that the address is associated with (if any).
35 36 37 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 35 def instance_id data[:instance_id] end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::EC2::VpcAddress. Returns ‘self` making it possible to chain methods.
vpc_address.reload.data
102 103 104 105 106 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 102 def load resp = @client.describe_addresses(allocation_ids: [@allocation_id]) @data = resp.addresses[0] self end |
#network_interface_id ⇒ String
The ID of the network interface.
61 62 63 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 61 def network_interface_id data[:network_interface_id] end |
#network_interface_owner_id ⇒ String
The ID of the AWS account that owns the network interface.
67 68 69 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 67 def network_interface_owner_id data[:network_interface_owner_id] end |
#private_ip_address ⇒ String
The private IP address associated with the Elastic IP address.
73 74 75 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 73 def private_ip_address data[:private_ip_address] end |
#public_ip ⇒ String
The Elastic IP address.
41 42 43 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 41 def public_ip data[:public_ip] end |
#public_ipv_4_pool ⇒ String
The ID of an address pool.
85 86 87 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 85 def public_ipv_4_pool data[:public_ipv_4_pool] end |
#release(options = {}) ⇒ EmptyStructure
282 283 284 285 286 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 282 def release( = {}) = .merge(allocation_id: data[:allocation_id]) resp = @client.release_address() resp.data end |
#tags ⇒ Array<Types::Tag>
Any tags assigned to the Elastic IP address.
79 80 81 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 79 def data[:tags] end |
#wait_until(options = {}, &block) ⇒ Resource
Use [Aws::EC2::Client] #wait_until instead
The waiting operation is performed on a copy. The original resource remains unchanged
Waiter polls an API operation until a resource enters a desired state.
## Basic Usage
Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop until condition is true
resource.wait_until() {|resource| condition}
## Example
instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
## Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:
# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}
## Callbacks
You can be notified before each polling attempt and before each delay. If you throw ‘:success` or `:failure` from these callbacks, it will terminate the waiter.
started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
# disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}
## Handling Errors
When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.
begin
resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
attempts attempt in seconds invoked before each attempt invoked before each wait
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/aws-sdk-ec2/vpc_address.rb', line 202 def wait_until( = {}, &block) self_copy = self.dup attempts = 0 [:max_attempts] = 10 unless .key?(:max_attempts) [:delay] ||= 10 [:poller] = Proc.new do attempts += 1 if block.call(self_copy) [:success, self_copy] else self_copy.reload unless attempts == [:max_attempts] :retry end end Aws::Waiters::Waiter.new().wait({}) end |