Documentation ¶
Overview ¶
Package awsrouter abstracts network resources in AWS. It create new types similar to AWS types, but with a few additions. Once the types are created and populated, they can operate without AWS access.
Index ¶
- Variables
- func ExportRouteTableRoutesCsv(w *csv.Writer, tgwrt TgwRouteTable) error
- func ExportTgwRoutesExcel(tgws []*Tgw, folder fs.FileInfo) error
- func GetNamesFromTags(tags []types.Tag) (string, error)
- type AttPath
- type Tgw
- func (t *Tgw) Bytes() []byte
- func (t *Tgw) GetDirectlyConnectedAttachment(ipAddress net.IP) (TgwRouteTable, []*TgwAttachment, error)
- func (t *Tgw) GetTgwRouteTableByID(id string) (*TgwRouteTable, error)
- func (t *Tgw) UpdateRouteTables(ctx context.Context, api ports.AWSRouter) error
- func (t *Tgw) UpdateTgwRouteTablesAttachments(ctx context.Context, api ports.AWSRouter) error
- func (t *Tgw) UpdateTgwRoutes(ctx context.Context, api ports.AWSRouter) error
- type TgwAttachment
- type TgwRouteTable
- func (t TgwRouteTable) BestRouteToIP(ipAddress net.IP) (types.TransitGatewayRoute, error)
- func (t *TgwRouteTable) Bytes() []byte
- func (t *TgwRouteTable) GetAttachmentName(attachmentID string) string
- func (t *TgwRouteTable) PrintRoutesInTable()
- func (t *TgwRouteTable) UpdateAttachments(ctx context.Context, ...) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ExportRouteTableRoutesCsv ¶
func ExportRouteTableRoutesCsv(w *csv.Writer, tgwrt TgwRouteTable) error
ExportRouteTableRoutesCsv creates a CSV with all the routes in one Tgw Route Table.
func ExportTgwRoutesExcel ¶
ExportTgwRoutesExcel creates a Excel with all the routes in all Tgw Route Tables. Each sheet on the Excel is a Tgw Route Table, each route is a route.
Types ¶
type AttPath ¶
type AttPath struct { // The list of attachments in the path, from source to destination. Path []*TgwAttachment // The source route table. SrcRouteTable TgwRouteTable // The destination route table. DstRouteTable TgwRouteTable // The Transit Gateway of this path. Tgw *Tgw // contains filtered or unexported fields }
AttPath is a list of TgwAttachments that represent the path from a source to a destination. The first element is the source attachment, the last element is the destination attachment. There can be 2 or more attachments in the path, but 2 or 3 are common values. No two elements are the same, because that would be a loop.
func (*AttPath) Walk ¶
Walk will do a packet walk from the src to dst and updates the field Path. The function will walk from one attachment to the next, until it reaches the dst. There is a limit of 10 hops. If the limit is reached, the function will return an error. TODO: allow the option to increase the depth of the walk, right now is 10.
type Tgw ¶
type Tgw struct { ID string Name string RouteTables []*TgwRouteTable Data types.TransitGateway }
Tgw is the main data-structure, holds ID, Name, a list of TgwRouteTable and other TGW info. Represents a Transit Gateway in AWS.
func GetAllTgws ¶
GetAllTgws returns a list of all the Transit Gateways in the account for specific region
func UpdateRouting ¶
UpdateRouting this functions is a helper that will update all routing information from AWS, returning a list of Tgw. The function will try to gather all the Route Tables and all the routes in the Route Tables. The function will return an error if it fails to gather a Transit Gateway or a Route Table, but it will continue if it fails to gather a route.
func (*Tgw) GetDirectlyConnectedAttachment ¶
func (t *Tgw) GetDirectlyConnectedAttachment(ipAddress net.IP) (TgwRouteTable, []*TgwAttachment, error)
GetDirectlyConnectedAttachment returns the route and attachment that is directly connected to the ipAddress. In the case of ECMP we can have more than one attachment per route. In the majority of the cases we will have only one attachment per route. If we have two or more attachments this function is unable will return the first attachment and the route table associated to it.
func (*Tgw) GetTgwRouteTableByID ¶
func (t *Tgw) GetTgwRouteTableByID(id string) (*TgwRouteTable, error)
func (*Tgw) UpdateRouteTables ¶
UpdateRouteTables updates the field TgwRouteTables on a Tgw. An error will stop the processing returning the error wrapped.
func (*Tgw) UpdateTgwRouteTablesAttachments ¶
UpdateTgwRouteTablesAttachments updates the Attachments of a TgwRouteTable.
func (*Tgw) UpdateTgwRoutes ¶
UpdateTgwRoutes updates the routes of a route table.
TODO: Add some sentinel error message to notify if a the calls to UpdateTgwRoutes fail. TODO: add testing and include race condition detection.
Each Tgw has a list of TgwRouteTables, each RouteTable gets is own goroutine.
type TgwAttachment ¶
type TgwAttachment struct { // The ID of the attachment. ID string // The ID of the resource where this attachment terminates. ResourceID string // The type of the resource where this attachment terminates. // Common values are: vpc, vpn, direct-connect ... Type string // The name of the TGW Attachment. Name string }
TgwAttachments holds the data of a Transit Gateway Attachment.
type TgwRouteTable ¶
type TgwRouteTable struct { ID string Name string Data types.TransitGatewayRouteTable Routes []types.TransitGatewayRoute Attachments []*TgwAttachment }
TgwRouteTable holds the Route Table ID, a list of routes and other RouteTable info. Represents a Route Table of a Transit Gateway in AWS.
func FilterRouteTableRoutesPerPrefix ¶
func FilterRouteTableRoutesPerPrefix(rts []*TgwRouteTable, prefix net.IPNet) ([]TgwRouteTable, error)
FilterRouteTableRoutesPerPrefix returns only the routes in the route table that match specific prefix. Every Route Table has only one route per prefix. The return list is created out of new TgwRouteTable structs, that copy only the matching route to the new table.
func TgwRouteTableSelectionPriority ¶
func TgwRouteTableSelectionPriority(rts []*TgwRouteTable, src net.IP) (*TgwRouteTable, error)
TgwRouteTableSelectionPriority select the best route table from a list of TgwRouteTables to the specific destination.
func (TgwRouteTable) BestRouteToIP ¶
func (t TgwRouteTable) BestRouteToIP(ipAddress net.IP) (types.TransitGatewayRoute, error)
BestRouteToIP returns the best route to a given IP address for a given TgwRouteTable. Only one route can be the best route, and is returned. If no route is found, the function returns the empty TransitGatewayRoute.
func (*TgwRouteTable) Bytes ¶
func (t *TgwRouteTable) Bytes() []byte
Bytes returns the JSON representation of the TgwRouteTable as a slice of bytes.
func (*TgwRouteTable) GetAttachmentName ¶ added in v0.1.5
func (t *TgwRouteTable) GetAttachmentName(attachmentID string) string
GetAttachmentName returns the name of the attachment that has the given ID.
func (*TgwRouteTable) PrintRoutesInTable ¶
func (t *TgwRouteTable) PrintRoutesInTable()
PrintRoutesInTable creates a table to print the routes in a route table.
func (*TgwRouteTable) UpdateAttachments ¶
func (t *TgwRouteTable) UpdateAttachments(ctx context.Context, attachments *ec2.GetTransitGatewayRouteTableAssociationsOutput) error
Update the attachments of a TgwRouteTable.