Class: Aws::EC2::Route

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb

Defined Under Namespace

Classes: Collection

Actions collapse

Associations collapse

Read-Only Attributes collapse

Instance Method Summary collapse

Constructor Details

#initialize(route_table_id, destination_cidr_block, options = {}) ⇒ Route #initialize(options = {}) ⇒ Route

Returns a new instance of Route.

Overloads:

  • #initialize(route_table_id, destination_cidr_block, options = {}) ⇒ Route

    Parameters:

    • route_table_id (String)
    • destination_cidr_block (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ Route

    Options Hash (options):

    • :route_table_id (required, String)
    • :destination_cidr_block (required, String)
    • :client (Client)


24
25
26
27
28
29
30
31
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 24

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @route_table_id = extract_route_table_id(args, options)
  @destination_cidr_block = extract_destination_cidr_block(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
  @waiter_block_warned = false
end

Instance Method Details

#clientClient

Returns:



137
138
139
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 137

def client
  @client
end

#dataTypes::Route

Returns the data for this Aws::EC2::Route.

Returns:

Raises:



152
153
154
155
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 152

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



160
161
162
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 160

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


route.delete({
  destination_ipv_6_cidr_block: "String",
  destination_prefix_list_id: "PrefixListResourceId",
  dry_run: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :destination_ipv_6_cidr_block (String)

    The IPv6 CIDR range for the route. The value you specify must match the CIDR for the route exactly.

  • :destination_prefix_list_id (String)

    The ID of the prefix list for the route.

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Returns:

  • (EmptyStructure)


282
283
284
285
286
287
288
289
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 282

def delete(options = {})
  options = options.merge(
    route_table_id: @route_table_id,
    destination_cidr_block: @destination_cidr_block
  )
  resp = @client.delete_route(options)
  resp.data
end

#destination_cidr_blockString

Returns:

  • (String)


41
42
43
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 41

def destination_cidr_block
  @destination_cidr_block
end

#destination_ipv_6_cidr_blockString

The IPv6 CIDR block used for the destination match.

Returns:

  • (String)


47
48
49
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 47

def destination_ipv_6_cidr_block
  data[:destination_ipv_6_cidr_block]
end

#destination_prefix_list_idString

The prefix of the AWS service.

Returns:

  • (String)


53
54
55
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 53

def destination_prefix_list_id
  data[:destination_prefix_list_id]
end

#egress_only_internet_gateway_idString

The ID of the egress-only internet gateway.

Returns:

  • (String)


59
60
61
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 59

def egress_only_internet_gateway_id
  data[:egress_only_internet_gateway_id]
end

#gateway_idString

The ID of a gateway attached to your VPC.

Returns:

  • (String)


65
66
67
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 65

def gateway_id
  data[:gateway_id]
end

#instance_idString

The ID of a NAT instance in your VPC.

Returns:

  • (String)


71
72
73
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 71

def instance_id
  data[:instance_id]
end

#instance_owner_idString

The AWS account ID of the owner of the instance.

Returns:

  • (String)


77
78
79
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 77

def instance_owner_id
  data[:instance_owner_id]
end

#local_gateway_idString

The ID of the local gateway.

Returns:

  • (String)


95
96
97
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 95

def local_gateway_id
  data[:local_gateway_id]
end

#nat_gateway_idString

The ID of a NAT gateway.

Returns:

  • (String)


83
84
85
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 83

def nat_gateway_id
  data[:nat_gateway_id]
end

#network_interface_idString

The ID of the network interface.

Returns:

  • (String)


101
102
103
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 101

def network_interface_id
  data[:network_interface_id]
end

#originString

Describes how the route was created.

  • CreateRouteTable - The route was automatically created when the route table was created.

  • CreateRoute - The route was manually added to the route table.

  • EnableVgwRoutePropagation - The route was propagated by route propagation.

Returns:

  • (String)


115
116
117
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 115

def origin
  data[:origin]
end

#replace(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


route.replace({
  destination_ipv_6_cidr_block: "String",
  destination_prefix_list_id: "PrefixListResourceId",
  dry_run: false,
  egress_only_internet_gateway_id: "EgressOnlyInternetGatewayId",
  gateway_id: "RouteGatewayId",
  instance_id: "InstanceId",
  local_target: false,
  nat_gateway_id: "NatGatewayId",
  transit_gateway_id: "TransitGatewayId",
  local_gateway_id: "LocalGatewayId",
  network_interface_id: "NetworkInterfaceId",
  vpc_peering_connection_id: "VpcPeeringConnectionId",
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :destination_ipv_6_cidr_block (String)

    The IPv6 CIDR address block used for the destination match. The value that you provide must match the CIDR of an existing route in the table.

  • :destination_prefix_list_id (String)

    The ID of the prefix list for the route.

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :egress_only_internet_gateway_id (String)

    [IPv6 traffic only] The ID of an egress-only internet gateway.

  • :gateway_id (String)

    The ID of an internet gateway or virtual private gateway.

  • :instance_id (String)

    The ID of a NAT instance in your VPC.

  • :local_target (Boolean)

    Specifies whether to reset the local route to its default target (local).

  • :nat_gateway_id (String)

    [IPv4 traffic only] The ID of a NAT gateway.

  • :transit_gateway_id (String)

    The ID of a transit gateway.

  • :local_gateway_id (String)

    The ID of the local gateway.

  • :network_interface_id (String)

    The ID of a network interface.

  • :vpc_peering_connection_id (String)

    The ID of a VPC peering connection.

Returns:

  • (EmptyStructure)


339
340
341
342
343
344
345
346
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 339

def replace(options = {})
  options = options.merge(
    route_table_id: @route_table_id,
    destination_cidr_block: @destination_cidr_block
  )
  resp = @client.replace_route(options)
  resp.data
end

#route_tableRouteTable

Returns:



351
352
353
354
355
356
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 351

def route_table
  RouteTable.new(
    id: @route_table_id,
    client: @client
  )
end

#route_table_idString

Returns:

  • (String)


36
37
38
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 36

def route_table_id
  @route_table_id
end

#stateString

The state of the route. The blackhole state indicates that the route's target isn't available (for example, the specified gateway isn't attached to the VPC, or the specified NAT instance has been terminated).

Returns:

  • (String)


124
125
126
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 124

def state
  data[:state]
end

#transit_gateway_idString

The ID of a transit gateway.

Returns:

  • (String)


89
90
91
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 89

def transit_gateway_id
  data[:transit_gateway_id]
end

#vpc_peering_connection_idString

The ID of a VPC peering connection.

Returns:

  • (String)


130
131
132
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 130

def vpc_peering_connection_id
  data[:vpc_peering_connection_id]
end

#wait_until(options = {}) {|resource| ... } ⇒ Resource

Deprecated.

Use [Aws::EC2::Client] #wait_until instead

Note:

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(options) {|resource| condition}

Example

instance.wait_until(max_attempts:10, delay:5) do |instance|
  instance.state.name == 'running'
end

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

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :max_attempts (Integer) — default: 10

    Maximum number of

  • :delay (Integer) — default: 10

    Delay between each

  • :before_attempt (Proc) — default: nil

    Callback

  • :before_wait (Proc) — default: nil

    Callback

Yield Parameters:

  • resource (Resource)

    to be used in the waiting condition.

Returns:

  • (Resource)

    if the waiter was successful

Raises:

  • (Aws::Waiters::Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

    yet successful.

  • (Aws::Waiters::Errors::UnexpectedError)

    Raised when an error is encountered while polling for a resource that is not expected.

  • (NotImplementedError)

    Raised when the resource does not



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/route.rb', line 244

def wait_until(options = {}, &block)
  self_copy = self.dup
  attempts = 0
  options[:max_attempts] = 10 unless options.key?(:max_attempts)
  options[:delay] ||= 10
  options[:poller] = Proc.new do
    attempts += 1
    if block.call(self_copy)
      [:success, self_copy]
    else
      self_copy.reload unless attempts == options[:max_attempts]
      :retry
    end
  end
  Aws::Waiters::Waiter.new(options).wait({})
end