class DrawCloud::RouteTableEntry

Attributes

name[RW]
to[RW]
via[RW]

Public Class Methods

new(name, to, via, options={}) click to toggle source
Calls superclass method DrawCloud::Base::new
# File lib/draw_cloud/route_table_entry.rb, line 22
def initialize(name, to, via, options={})
  @name = name
  @to = to
  @via = via
  super(options)
end

Public Instance Methods

load_into_config(config) click to toggle source
Calls superclass method DrawCloud::Base#load_into_config
# File lib/draw_cloud/route_table_entry.rb, line 29
def load_into_config(config)
  # FIXME: emit error if no table attached
  config.cf_add_resource resource_name, self
  super(config)
end
resource_name() click to toggle source
# File lib/draw_cloud/route_table_entry.rb, line 35
def resource_name
  route_table.resource_name + "To" + resource_style(name)
end
to_h() click to toggle source
# File lib/draw_cloud/route_table_entry.rb, line 39
def to_h
  h = {
    "Type" => "AWS::EC2::Route",
    "Properties" => {
      "RouteTableId" => DrawCloud.ref(route_table),
      "DestinationCidrBlock" => to,
    }
  }
  if via.nil?
    throw ArgumentError, "Route #{resource_name} requires :via"
  elsif via.internet_gateway
    h["Properties"]["GatewayId"] = DrawCloud.ref(via.internet_gateway)
    # TODO: ["NetworkInterfaceId"]
  elsif via.ec2_instance
    h["Properties"]["InstanceId"] = DrawCloud.ref(via.ec2_instance)
  end

  add_standard_properties(h)
end