/
transitgateway.go
633 lines (582 loc) · 19.4 KB
/
transitgateway.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
package hatchery
import (
"fmt"
"os"
"strings"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
)
// This function sets up the transit gateway between the account hatchery is running in, and the account workspaces will run.
func setupTransitGateway(userName string) error {
// Create new AWS session to be used by this function
sess := session.Must(session.NewSession(&aws.Config{
// TODO: Make this configurable
Region: aws.String("us-east-1"),
}))
pm, err := getCurrentPayModel(userName)
if err != nil {
return err
}
Config.Logger.Printf("Setting up transit gateway in main account")
tgwid, tgwarn, tgwRouteTableId, err := createTransitGateway(sess, userName)
if err != nil {
return fmt.Errorf("error creating transit gateway: %s", err.Error())
}
// This transit gateway attachment connects the main account to the remote account
// This is needed once per environment, instead of once per user.
err = createLocalTransitGatewayAttachment(userName, *tgwid, tgwRouteTableId)
if err != nil {
return fmt.Errorf("error creating local transit gateway attachment: %s", err.Error())
}
// Make sure transit gateway is shared with the remote account
ramArn, err := shareTransitGateway(sess, *tgwarn, pm.AWSAccountId)
if err != nil {
return err
}
// Accept transit gateway share in remote account
err = acceptTransitGatewayShare(pm, sess, ramArn)
if err != nil {
return err
}
Config.Logger.Printf("Setting up remote account ")
err = setupRemoteAccount(userName, false)
if err != nil {
return fmt.Errorf("failed to setup remote account: %s", err.Error())
}
return nil
}
func createLocalTransitGatewayAttachment(userName string, tgwid string, tgwRouteTableId *string) error {
vpcid := os.Getenv("GEN3_VPCID")
sess := session.Must(session.NewSession(&aws.Config{
// TODO: Make this configurable
Region: aws.String("us-east-1"),
}))
// ec2 session to main AWS account.
ec2Local := ec2.New(sess)
// Create Transit Gateway Attachment in local VPC
// Config.Logger.Printf("Creating tgw attachment in local VPC: %s", vpcid)
tgwAttachment, err := createTransitGatewayAttachments(ec2Local, vpcid, tgwid, true, nil, userName)
if err != nil {
return err
}
Config.Logger.Printf("Attachment created: %s", *tgwAttachment)
// Create Transit Gateway Route Table
err = TGWRoutes(userName, tgwRouteTableId, tgwAttachment, ec2Local, true, false, nil)
if err != nil {
// Log error
Config.Logger.Printf("Failed to create TGW route table: %s", err.Error())
return err
}
return nil
}
func teardownTransitGateway(userName string) error {
Config.Logger.Printf("Terminating remote transit gateway attachment for user %s\n", userName)
err := setupRemoteAccount(userName, true)
if err != nil {
return err
}
return nil
}
func describeMainNetwork(vpcid string, svc *ec2.EC2) (*NetworkInfo, error) {
networkInfo := NetworkInfo{}
vpcInput := &ec2.DescribeVpcsInput{
Filters: []*ec2.Filter{
{
Name: aws.String("tag:Name"),
Values: []*string{aws.String(vpcid)},
},
},
}
vpc, err := svc.DescribeVpcs(vpcInput)
if err != nil {
return nil, err
}
if len(vpc.Vpcs) == 0 {
return nil, fmt.Errorf("no VPC's found in hub account: %s", vpc)
}
// Get VPC CIDR blocks
for _, cidr := range vpc.Vpcs[0].CidrBlockAssociationSet {
// append to networkInfo struct
networkInfo.vpcCidrBlocks = append(networkInfo.vpcCidrBlocks, cidr.CidrBlock)
}
subnetInput := &ec2.DescribeSubnetsInput{
Filters: []*ec2.Filter{
{
Name: aws.String("vpc-id"),
Values: []*string{aws.String(*vpc.Vpcs[0].VpcId)},
},
{
Name: aws.String("tag:Name"),
Values: []*string{aws.String("eks_private_0"), aws.String("eks_private_1"), aws.String("eks_private_2")},
},
},
}
subnets, err := svc.DescribeSubnets(subnetInput)
if err != nil {
return nil, err
}
if len(subnets.Subnets) == 0 {
return nil, fmt.Errorf("no subnets found: %s", subnets)
}
routeTableInput := &ec2.DescribeRouteTablesInput{
Filters: []*ec2.Filter{
{
Name: aws.String("vpc-id"),
Values: []*string{vpc.Vpcs[0].VpcId},
},
{
Name: aws.String("tag:Name"),
Values: []*string{aws.String("eks_private")},
},
},
}
routeTable, err := svc.DescribeRouteTables(routeTableInput)
if err != nil {
return nil, err
}
networkInfo.vpc = vpc
networkInfo.subnets = subnets
networkInfo.routeTable = routeTable
return &networkInfo, nil
}
func createTransitGateway(sess *session.Session, userName string) (tgwid *string, tgwarn *string, tgwRouteTableId *string, err error) {
// ec2 session to main AWS account.
ec2Local := ec2.New(sess)
tgwName := strings.ReplaceAll(os.Getenv("GEN3_ENDPOINT"), ".", "-") + "-tgw"
// Check for existing transit gateway
exTg, err := ec2Local.DescribeTransitGateways(&ec2.DescribeTransitGatewaysInput{
Filters: []*ec2.Filter{
{
Name: aws.String("state"),
Values: []*string{aws.String("available"), aws.String("pending")},
},
{
Name: aws.String("tag:Name"),
Values: []*string{aws.String(tgwName)},
},
},
})
if err != nil {
return nil, nil, nil, fmt.Errorf("failed to DescribeTransitGateways: %s", err.Error())
}
// Create Transit Gateway if it doesn't exist
if len(exTg.TransitGateways) == 0 {
Config.Logger.Printf("No transit gateway found. Creating one...")
tgwName := strings.ReplaceAll(os.Getenv("GEN3_ENDPOINT"), ".", "-") + "-tgw"
tg, err := ec2Local.CreateTransitGateway(&ec2.CreateTransitGatewayInput{
DryRun: aws.Bool(false),
Description: aws.String("Transit gateway to connect external VPC's"),
Options: &ec2.TransitGatewayRequestOptions{
AutoAcceptSharedAttachments: aws.String("enable"),
DefaultRouteTablePropagation: aws.String("disable"),
},
TagSpecifications: []*ec2.TagSpecification{
{
ResourceType: aws.String("transit-gateway"),
Tags: []*ec2.Tag{
{
Key: aws.String("Name"),
Value: aws.String(tgwName),
},
{
Key: aws.String("Environment"),
Value: aws.String(os.Getenv("GEN3_ENDPOINT")),
},
},
},
},
})
if err != nil {
return nil, nil, nil, err
}
Config.Logger.Printf("Transit gateway created: %s", *tg.TransitGateway.TransitGatewayId)
return tg.TransitGateway.TransitGatewayId, tg.TransitGateway.TransitGatewayArn, tg.TransitGateway.Options.AssociationDefaultRouteTableId, nil
} else {
Config.Logger.Print("Existing transit gateway found. Skipping creation...")
return exTg.TransitGateways[len(exTg.TransitGateways)-1].TransitGatewayId, exTg.TransitGateways[len(exTg.TransitGateways)-1].TransitGatewayArn, exTg.TransitGateways[len(exTg.TransitGateways)-1].Options.AssociationDefaultRouteTableId, nil
}
}
func createTransitGatewayAttachments(svc *ec2.EC2, vpcid string, tgwid string, local bool, sess *CREDS, userName string) (*string, error) {
Config.Logger.Printf("Creating transit gateway attachment for VPC: %s", vpcid)
// Check for existing transit gateway
tgInput := &ec2.DescribeTransitGatewaysInput{
TransitGatewayIds: []*string{aws.String(tgwid)},
Filters: []*ec2.Filter{
{
Name: aws.String("state"),
Values: []*string{aws.String("available"), aws.String("pending")},
},
},
}
var exTg *ec2.DescribeTransitGatewaysOutput
var err error
maxRetries := 10
retryInterval := 10 * time.Second
for i := 0; i < maxRetries; i++ {
exTg, err = svc.DescribeTransitGateways(tgInput)
if err == nil {
// Successfully described the Transit Gateway
break
}
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case "InvalidTransitGatewayID.NotFound":
// Sleep for the retry interval before trying again
Config.Logger.Printf("TransitGateway not found, retrying in %s", retryInterval.String())
time.Sleep(retryInterval)
default:
return nil, fmt.Errorf("cannot DescribeTransitGateways: %s", err.Error())
}
} else {
// Some other error occurred, return it immediately
return nil, fmt.Errorf("cannot DescribeTransitGateways: %s", err.Error())
}
// If we've reached the maximum number of retries, return an error
if i == maxRetries-1 {
return nil, fmt.Errorf("maximum number of retries reached")
}
}
for *exTg.TransitGateways[0].State != "available" {
Config.Logger.Printf("TransitGateway is in state: %s ... Waiting for 10 seconds", *exTg.TransitGateways[0].State)
// sleep for 10 sec
time.Sleep(10 * time.Second)
exTg, _ = svc.DescribeTransitGateways(tgInput)
}
var networkInfo *NetworkInfo
if local {
networkInfo, err = describeMainNetwork(vpcid, svc)
} else {
networkInfo, err = sess.describeWorkspaceNetwork(userName)
}
if err != nil {
return nil, fmt.Errorf("Failed to get network info: %s", err)
}
tgwAttachmentName := ""
if local {
// Name the local tgwAttachment after the environment, instead of the user.
// This is shared between all users in the environment.
tgwAttachmentName = os.Getenv("GEN3_ENDPOINT") + "-tgwa"
} else {
tgwAttachmentName = userToResourceName(userName, "service") + "tgwa"
}
exTgwAttachmentInput := &ec2.DescribeTransitGatewayAttachmentsInput{
Filters: []*ec2.Filter{
{
Name: aws.String("tag:Environment"),
Values: []*string{aws.String(os.Getenv("GEN3_ENDPOINT"))},
},
{
Name: aws.String("resource-id"),
Values: []*string{networkInfo.vpc.Vpcs[0].VpcId},
},
{
Name: aws.String("state"),
Values: []*string{aws.String("available"), aws.String("pending")},
},
},
}
exTgwAttachment, err := svc.DescribeTransitGatewayAttachments(exTgwAttachmentInput)
if err != nil {
return nil, err
}
if len(exTgwAttachment.TransitGatewayAttachments) == 0 {
// Create the transit gateway attachment
Config.Logger.Printf("Local transitgateway attachment not found, creating new one")
tgwAttachmentInput := &ec2.CreateTransitGatewayVpcAttachmentInput{
TransitGatewayId: exTg.TransitGateways[0].TransitGatewayId,
VpcId: networkInfo.vpc.Vpcs[len(networkInfo.vpc.Vpcs)-1].VpcId,
TagSpecifications: []*ec2.TagSpecification{
{
ResourceType: aws.String("transit-gateway-attachment"),
Tags: []*ec2.Tag{
{
Key: aws.String("Name"),
Value: aws.String(tgwAttachmentName),
},
{
Key: aws.String("Environment"),
Value: aws.String(os.Getenv("GEN3_ENDPOINT")),
},
},
},
},
}
for i := range networkInfo.subnets.Subnets {
tgwAttachmentInput.SubnetIds = append(tgwAttachmentInput.SubnetIds, networkInfo.subnets.Subnets[i].SubnetId)
}
tgwAttachment, err := svc.CreateTransitGatewayVpcAttachment(tgwAttachmentInput)
if err != nil {
return nil, fmt.Errorf("cannot create transitgatewayattachment: %s", err.Error())
}
Config.Logger.Printf("Created transitgatewayattachment: %s", *tgwAttachment.TransitGatewayVpcAttachment.TransitGatewayAttachmentId)
return tgwAttachment.TransitGatewayVpcAttachment.TransitGatewayAttachmentId, nil
} else {
Config.Logger.Printf("Local transitgateway attachment found, using existing one")
return exTgwAttachment.TransitGatewayAttachments[0].TransitGatewayAttachmentId, nil
}
}
func deleteTransitGatewayAttachment(svc *ec2.EC2, tgwid string, userName string) (*string, error) {
tgwAttachmentName := userToResourceName(userName, "service") + "tgwa"
exTgwAttachmentInput := &ec2.DescribeTransitGatewayAttachmentsInput{
Filters: []*ec2.Filter{
{
Name: aws.String("transit-gateway-id"),
Values: []*string{aws.String(tgwid)},
},
{
Name: aws.String("state"),
Values: []*string{aws.String("available"), aws.String("pending")},
},
{
Name: aws.String("tag:Name"),
Values: []*string{
aws.String(tgwAttachmentName),
},
},
{
Name: aws.String("tag:Environment"),
Values: []*string{
aws.String(os.Getenv("GEN3_ENDPOINT")),
},
},
},
}
exTgwAttachment, err := svc.DescribeTransitGatewayAttachments(exTgwAttachmentInput)
if err != nil {
Config.Logger.Printf("Error: %s", err.Error())
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case "InvalidTransitGatewayID.NotFound":
// No TGW attachment found, we are happy :)
return nil, nil
}
} else {
Config.Logger.Printf("Error: %s", err.Error())
return nil, err
}
}
if len(exTgwAttachment.TransitGatewayAttachments) == 0 {
// No transit gateway attachment found, we are happy :)
Config.Logger.Printf("No TGW attachment found, we are happy :)")
return nil, nil
}
delTGWAttachmentInput := &ec2.DeleteTransitGatewayVpcAttachmentInput{
TransitGatewayAttachmentId: exTgwAttachment.TransitGatewayAttachments[0].TransitGatewayAttachmentId,
}
delTGWAttachment, err := svc.DeleteTransitGatewayVpcAttachment(delTGWAttachmentInput)
if err != nil {
return nil, err
}
return delTGWAttachment.TransitGatewayVpcAttachment.TransitGatewayAttachmentId, nil
}
func setupRemoteAccount(userName string, teardown bool) error {
pm, err := getCurrentPayModel(userName)
if err != nil {
return err
}
roleARN := "arn:aws:iam::" + pm.AWSAccountId + ":role/csoc_adminvm"
sess := session.Must(session.NewSession(&aws.Config{
// TODO: Make this configurable
Region: aws.String("us-east-1"),
}))
svc := NewSVC(sess, roleARN)
ec2Local := ec2.New(sess)
ec2Remote := ec2.New(session.Must(session.NewSession(&aws.Config{
Credentials: svc.creds,
Region: aws.String("us-east-1"),
})))
vpcid := os.Getenv("GEN3_VPCID")
exTgInput := &ec2.DescribeTransitGatewaysInput{
Filters: []*ec2.Filter{
{
Name: aws.String("state"),
Values: []*string{aws.String("available"), aws.String("pending")},
},
{
Name: aws.String("tag:Environment"),
Values: []*string{aws.String(os.Getenv("GEN3_ENDPOINT"))},
},
},
}
exTg, err := ec2Local.DescribeTransitGateways(exTgInput)
if err != nil {
return err
}
for len(exTg.TransitGateways) == 0 {
Config.Logger.Printf("Waiting to find ex_tgw")
// err := svc.acceptTGWShare()
// if err != nil {
// return err
// }
exTg, err = ec2Local.DescribeTransitGateways(exTgInput)
if err != nil {
return err
}
time.Sleep(5 * time.Second)
}
networkInfo, err := svc.describeWorkspaceNetwork(userName)
if err != nil {
return err
}
vpc := *networkInfo.vpc
mainNetworkInfo, err := describeMainNetwork(vpcid, ec2Local)
if err != nil {
return err
}
var tgw_attachment *string
if teardown {
tgw_attachment, err = deleteTransitGatewayAttachment(ec2Remote, *exTg.TransitGateways[0].TransitGatewayId, userName)
if err != nil {
return err
}
} else {
tgw_attachment, err = createTransitGatewayAttachments(ec2Remote, *vpc.Vpcs[0].VpcId, *exTg.TransitGateways[0].TransitGatewayId, false, &svc, userName)
if err != nil {
return fmt.Errorf("Cannot create remote TransitGatewayAttachment: %s", err.Error())
}
Config.Logger.Printf("tgw_attachment: %s", *tgw_attachment)
}
// setup Transit Gateway Route Table
err = TGWRoutes(userName, exTg.TransitGateways[0].Options.AssociationDefaultRouteTableId, tgw_attachment, ec2Local, false, teardown, &svc)
if err != nil {
return fmt.Errorf("Cannot create TGW Route: %s", err.Error())
}
// setup VPC Route Table
err = VPCRoutes(networkInfo, mainNetworkInfo, exTg.TransitGateways[0].TransitGatewayId, ec2Remote, ec2Local, teardown)
if err != nil {
return fmt.Errorf("failed to create vpc routes: %s", err.Error())
}
return nil
}
func TGWRoutes(userName string, tgwRoutetableId *string, tgwAttachmentId *string, svc *ec2.EC2, local bool, teardown bool, sess *CREDS) error {
var networkInfo *NetworkInfo
vpcid := os.Getenv("GEN3_VPCID")
err := *new(error)
if local {
networkInfo, err = describeMainNetwork(vpcid, svc)
if err != nil {
return err
}
} else {
networkInfo, err = sess.describeWorkspaceNetwork(userName)
if err != nil {
return err
}
}
tgwAttachmentInput := &ec2.DescribeTransitGatewayAttachmentsInput{
TransitGatewayAttachmentIds: []*string{tgwAttachmentId},
}
tgwAttachment, err := svc.DescribeTransitGatewayAttachments(tgwAttachmentInput)
if err != nil {
return fmt.Errorf("error DescribeTransitGatewayAttachments: %s", err.Error())
}
if teardown {
// delete routes to all VPC CIDR blocks
for _, cidr := range networkInfo.vpcCidrBlocks {
Config.Logger.Printf("Deleting route to %s in transit gateway route table %s", *cidr, *tgwRoutetableId)
err := deleteTGWRoute(tgwRoutetableId, cidr, svc)
if err != nil {
return err
}
}
return nil
} else {
for *tgwAttachment.TransitGatewayAttachments[0].State != "available" {
Config.Logger.Printf("Transit Gateway Attachment is not ready. State is: %s", *tgwAttachment.TransitGatewayAttachments[0].State)
tgwAttachment, err = svc.DescribeTransitGatewayAttachments(tgwAttachmentInput)
if err != nil {
return err
}
time.Sleep(5 * time.Second)
}
// create routes to all VPC CIDR blocks
for _, cidr := range networkInfo.vpcCidrBlocks {
Config.Logger.Printf("Creating route to %s in transit gateway route table %s", *cidr, *tgwRoutetableId)
err := createTGWRoute(tgwRoutetableId, cidr, tgwAttachment.TransitGatewayAttachments[0].TransitGatewayAttachmentId, local, svc)
if err != nil {
return err
}
}
return nil
}
}
func deleteTGWRoute(routeTableId *string, cidrBlock *string, svc *ec2.EC2) error {
Config.Logger.Printf("Deleting route to %s from route table %s", *cidrBlock, *routeTableId)
delRouteInput := &ec2.DeleteTransitGatewayRouteInput{
DestinationCidrBlock: cidrBlock,
TransitGatewayRouteTableId: routeTableId,
}
_, err := svc.DeleteTransitGatewayRoute(delRouteInput)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case "InvalidRoute.NotFound":
// Route already deleted, we are happy :)
return nil
}
}
return err
}
return nil
}
func createTGWRoute(routeTableId *string, cidrBlock *string, attachmentId *string, local bool, svc *ec2.EC2) error {
// Check if route already exists.
// If it exists make sure it's not blackholed, and if it is delete it.
// If it doesn't exist, create the route in the transit gateway route table
exRoutesInput := &ec2.SearchTransitGatewayRoutesInput{
TransitGatewayRouteTableId: routeTableId,
Filters: []*ec2.Filter{
{
Name: aws.String("route-search.subnet-of-match"),
Values: []*string{cidrBlock},
},
},
}
exRoutes, err := svc.SearchTransitGatewayRoutes(exRoutesInput)
if err != nil {
// log error
Config.Logger.Printf("error SearchTransitGatewayRoutes: %s", err.Error())
return err
}
if len(exRoutes.Routes) == 1 {
if local {
// Delete route only if it's blackhole route
if *exRoutes.Routes[0].State == "blackhole" {
Config.Logger.Printf("Route is blackhole, deleting")
delRouteInput := &ec2.DeleteTransitGatewayRouteInput{
DestinationCidrBlock: cidrBlock,
TransitGatewayRouteTableId: routeTableId,
}
_, err := svc.DeleteTransitGatewayRoute(delRouteInput)
if err != nil {
return err
}
} else {
Config.Logger.Printf("Route to %s already exists in routeTable %s", *cidrBlock, *routeTableId)
return nil
}
} else {
delRouteInput := &ec2.DeleteTransitGatewayRouteInput{
DestinationCidrBlock: cidrBlock,
TransitGatewayRouteTableId: routeTableId,
}
_, err := svc.DeleteTransitGatewayRoute(delRouteInput)
if err != nil {
return err
}
}
}
tgRouteInput := &ec2.CreateTransitGatewayRouteInput{
TransitGatewayRouteTableId: routeTableId,
DestinationCidrBlock: cidrBlock,
TransitGatewayAttachmentId: attachmentId,
}
_, err = svc.CreateTransitGatewayRoute(tgRouteInput)
if err != nil {
return err
}
return nil
}