Class: Awscli::EC2::RouteTable

Inherits:
Object
  • Object
show all
Defined in:
lib/awscli/ec2.rb

Overview

> Subnet

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ RouteTable

Returns a new instance of RouteTable.



788
789
790
# File 'lib/awscli/ec2.rb', line 788

def initialize(connection)
  @conn = connection
end

Instance Method Details

#associate_route_table(options) ⇒ Object



826
827
828
829
# File 'lib/awscli/ec2.rb', line 826

def associate_route_table(options)
  @conn.associate_route_table(options[:route_table_id], options[:subnet_id])
  puts "Associated route table: #{options[:route_table_id]} with subnet: #{options[:subnet_id]}"
end

#create(options) ⇒ Object



801
802
803
804
# File 'lib/awscli/ec2.rb', line 801

def create(options)
  @conn.create_route_table(options[:vpc_id])
  puts "Created route table"
end

#create_route(options) ⇒ Object



806
807
808
809
810
811
812
813
814
# File 'lib/awscli/ec2.rb', line 806

def create_route(options)
  @conn.create_route(
    options[:route_table_id], 
    options[:dest_cidr],
    options[:gateway_id] || nil, 
    options[:instance_id] || nil, 
    options[:net_interface_id] || nil)
  puts "Created specified route"
end

#delete(options) ⇒ Object



816
817
818
819
# File 'lib/awscli/ec2.rb', line 816

def delete(options)
  @conn.delete_route_table(options[:route_table_id])
  puts "Deleted route table with id #{options[:route_table_id]}"
end

#delete_route(options) ⇒ Object



821
822
823
824
# File 'lib/awscli/ec2.rb', line 821

def delete_route(options)
  @conn.delete_route(options[:route_table_id], options[:dest_cidr])
  puts "Deleted route from routetable: #{options[:route_table_id]} with destination cidr: #{options[:dest_cidr]}"
end

#disassociate_route_table(options) ⇒ Object



831
832
833
834
# File 'lib/awscli/ec2.rb', line 831

def disassociate_route_table(options)
  @conn.disassociate_route_table(options[:association_id])
  puts "Disassociated route talbe with association_id: #{options[:association_id]}"
end

#list(options) ⇒ Object



792
793
794
795
796
797
798
799
# File 'lib/awscli/ec2.rb', line 792

def list(options)
  if options[:route_table_id]
    puts @conn.describe_route_tables('route-table-id' => options[:route_table_id].split(',')).body['routeTableSet'].to_yaml
  else
    Formatador.display_line("[green]#{@conn.describe_route_tables.body['routeTableSet'].map {|k| k['associationSet'].first}.map{|k| k['routeTableId']}}[/]")
    puts "For more info on a specific route table pass route-table-id to '--route-table-id' or '-r' of `list` subcommand"
  end
end