func GetActiveRoutesForTransitGatewayRouteTable(routetableID string, svc *ec2.Client) []TransitGatewayRoute {
	var result []TransitGatewayRoute
	desiredState := "active"
	params := &ec2.SearchTransitGatewayRoutesInput{
		TransitGatewayRouteTableId: &routetableID,
		Filters: []types.Filter{
			{
				Name:   aws.String("state"),
				Values: []string{desiredState},
			},
		},
	}
	resp, err := svc.SearchTransitGatewayRoutes(context.TODO(), params)
	if err != nil {
		panic(err)
	}
	for _, route := range resp.Routes {
		resourceid := *route.TransitGatewayAttachments[0].ResourceId
		// We don't care about the public IPs of the routes, so strip those off
		if route.TransitGatewayAttachments[0].ResourceType == types.TransitGatewayAttachmentResourceTypeVpn {
			resourceid = strings.Split(resourceid, "(")[0]
		}
		tgwroute := TransitGatewayRoute{
			State: string(route.State),
			CIDR:  *route.DestinationCidrBlock,
			Attachment: TransitGatewayAttachment{
				ID:         *route.TransitGatewayAttachments[0].TransitGatewayAttachmentId,
				ResourceID: resourceid,
			},
			RouteType: string(route.Type),
		}
		result = append(result, tgwroute)
	}
	return result
}
// GetActiveRoutesForTransitGatewayRouteTable returns all routes that are currently active for a Transit Gateway route table
GetActiveRoutesForTransitGatewayRouteTable returns all routes that are currently active for a Transit Gateway route table
// GetActiveRoutesForTransitGatewayRouteTable returns all routes that are currently active for a Transit Gateway route table
func GetActiveRoutesForTransitGatewayRouteTable(routetableID string, svc *ec2.Client) []TransitGatewayRoute {
	var result []TransitGatewayRoute
	desiredState := "active"
	params := &ec2.SearchTransitGatewayRoutesInput{
		TransitGatewayRouteTableId: &routetableID,
		Filters: []types.Filter{
			{
				Name:   aws.String("state"),
				Values: []string{desiredState},
			},
		},
	}
	resp, err := svc.SearchTransitGatewayRoutes(context.TODO(), params)
	if err != nil {
		panic(err)
	}
	for _, route := range resp.Routes {
		resourceid := *route.TransitGatewayAttachments[0].ResourceId
		if route.TransitGatewayAttachments[0].ResourceType == types.TransitGatewayAttachmentResourceTypeVpn {
			resourceid = strings.Split(resourceid, "(")[0]
		}
		tgwroute := TransitGatewayRoute{
			State: string(route.State),
			CIDR:  *route.DestinationCidrBlock,
			Attachment: TransitGatewayAttachment{
				ID:         *route.TransitGatewayAttachments[0].TransitGatewayAttachmentId,
				ResourceID: resourceid,
			},
			RouteType: string(route.Type),
		}
		result = append(result, tgwroute)
	}
	return result
}
func GetActiveRoutesForTransitGatewayRouteTable ( routetableID string , svc * ec2 . Client ) [ ] TransitGatewayRoute { var result [ ] TransitGatewayRoute desiredState := " " params := & ec2 . SearchTransitGatewayRoutesInput { TransitGatewayRouteTableId : & routetableID , Filters : [ ] types . Filter { { Name : aws . String ( " " ) , Values : [ ] string { desiredState } , } , } , } resp , err := svc . SearchTransitGatewayRoutes ( context . TODO ( ) , params ) if err != nil { panic ( err ) } for _ , route := range resp . Routes { resourceid := * route . TransitGatewayAttachments [ 0 ] . ResourceId if route . TransitGatewayAttachments [ 0 ] . ResourceType == types . TransitGatewayAttachmentResourceTypeVpn { resourceid = strings . Split ( resourceid , " " ) [ 0 ] } tgwroute := TransitGatewayRoute { State : string ( route . State ) , CIDR : * route . DestinationCidrBlock , Attachment : TransitGatewayAttachment { ID : * route . TransitGatewayAttachments [ 0 ] . TransitGatewayAttachmentId , ResourceID : resourceid , } , RouteType : string ( route . Type ) , } result = append ( result , tgwroute ) } return result }
GetActiveRoutesForTransitGatewayRouteTable returns all routes that are currently active for a Transit Gateway route table
GetActiveRoutesForTransitGatewayRouteTable returns all routes that are currently active for a Transit Gateway route table
// We don't care about the public IPs of the routes, so strip those off